Skip to content

request_output

Patched vLLM RequestOutput class with encrypted text fields.

Only requests explicitly marked for plaintext debugging in the registry bypass encryption, metadata scrubbing, and encrypted aggregation. An absent or retired registry entry always retains the fail-closed encryption behavior.

Warning

Under almost no circumstances should you need to import this module directly. If stainedglass_output_protection is installed, vLLM loads it automatically via the vllm.general_plugins entry point.

Classes:

Name Description
EncryptedRequestOutput

RequestOutput with user-facing text encrypted upon instantiation.

Functions:

Name Description
patch_request_output

Replace vLLM's RequestOutput with EncryptedRequestOutput everywhere it is already bound.

EncryptedRequestOutput

Bases: RequestOutput

RequestOutput with user-facing text encrypted upon instantiation.

Methods:

Name Description
__init__

Encrypt the string fields of a RequestOutput before initializing it.

add

Merge subsequent RequestOutput into this one, accounting for encrypted fields.

encrypt

Encrypt the string fields of the RequestOutput in place.

Attributes:

Name Type Description
key_registry Mapping[str, SessionKey | None]

Read only typed reference to the class's shared key registry.

key_registry property

key_registry: Mapping[str, SessionKey | None]

Read only typed reference to the class's shared key registry.

__init__

__init__(
    request_id: str,
    prompt: str | None,
    prompt_token_ids: list[int] | None,
    prompt_logprobs: PromptLogprobs | None,
    outputs: list[CompletionOutput],
    finished: bool,
    metrics: RequestStateStats | None = None,
    lora_request: LoRARequest | None = None,
    encoder_prompt: str | None = None,
    encoder_prompt_token_ids: list[int] | None = None,
    num_cached_tokens: int | None = None,
    *,
    kv_transfer_params: dict[str, Any] | None = None,
    **kwargs: Any,
) -> None

Encrypt the string fields of a RequestOutput before initializing it.

Parameters:

Name Type Description Default

request_id

str

The unique ID of the request.

required

prompt

str | None

The prompt string of the request. For encoder/decoder models, this is the decoder input prompt.

required

prompt_token_ids

list[int] | None

The token IDs of the prompt. For encoder/decoder models, this is the decoder input prompt token ids.

required

prompt_logprobs

PromptLogprobs | None

The log probabilities to return per prompt token.

required

outputs

list[CompletionOutput]

The output sequences of the request.

required

finished

bool

Whether the whole request is finished.

required

metrics

RequestStateStats | None

Metrics associated with the request.

None

lora_request

LoRARequest | None

The LoRA request that was used to generate the output.

None

encoder_prompt

str | None

The encoder prompt string of the request. None if decoder-only.

None

encoder_prompt_token_ids

list[int] | None

The token IDs of the encoder prompt. None if decoder-only.

None

num_cached_tokens

int | None

The number of tokens with prefix cache hit.

None

kv_transfer_params

dict[str, Any] | None

The params for remote K/V transfer.

None

**kwargs

Any

Keyword arguments for RequestOutput.

required

Raises:

Type Description
NotImplementedError

If encoder_prompt is not None. Encoder models are not currently supported.

NotImplementedError

If encoder_prompt_token_ids is not None. Encoder models are not currently supported.

NotImplementedError

If prompt_logprobs is not None. List of log probabilities cannot be encrypted, currently.

NotImplementedError

If multi_modal_placeholders is not None. Multimodal models are not currently supported.

add

Merge subsequent RequestOutput into this one, accounting for encrypted fields.

Parameters:

Name Type Description Default

next_output

RequestOutput

The next RequestOutput to merge.

required

aggregate

bool

Whether to aggregate metrics.

required

Raises:

Type Description
TypeError

If next_output is not an EncryptedRequestOutput.

encrypt

encrypt() -> None

Encrypt the string fields of the RequestOutput in place.

This method can be used to re-encrypt the fields if they were modified after initialization.

patch_request_output

patch_request_output() -> None

Replace vLLM's RequestOutput with EncryptedRequestOutput everywhere it is already bound.

Patching vllm.outputs alone is not enough: vllm.v1.engine.output_processor does from vllm.outputs import RequestOutput and constructs the class through that module-local binding. Rebinding every stale reference in sys.modules makes this patch hold by construction.

Idempotent. Modules are never imported here. A binding that does not exist yet will pick up the patched class from vllm.outputs when it is created.