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 |
|
Functions:
| Name | Description |
|---|---|
patch_request_output |
Replace vLLM's |
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 |
|---|---|---|---|
|
str
|
The unique ID of the request. |
required |
|
str | None
|
The prompt string of the request. For encoder/decoder models, this is the decoder input prompt. |
required |
|
list[int] | None
|
The token IDs of the prompt. For encoder/decoder models, this is the decoder input prompt token ids. |
required |
|
PromptLogprobs | None
|
The log probabilities to return per prompt token. |
required |
|
list[CompletionOutput]
|
The output sequences of the request. |
required |
|
bool
|
Whether the whole request is finished. |
required |
|
RequestStateStats | None
|
Metrics associated with the request. |
None
|
|
LoRARequest | None
|
The LoRA request that was used to generate the output. |
None
|
|
str | None
|
The encoder prompt string of the request. None if decoder-only. |
None
|
|
list[int] | None
|
The token IDs of the encoder prompt. None if decoder-only. |
None
|
|
int | None
|
The number of tokens with prefix cache hit. |
None
|
|
dict[str, Any] | None
|
The params for remote K/V transfer. |
None
|
|
Any
|
Keyword arguments for |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
NotImplementedError
|
If |
NotImplementedError
|
If |
NotImplementedError
|
If |
add
¶
add(next_output: RequestOutput, aggregate: bool) -> None
Merge subsequent RequestOutput into this one, accounting for encrypted fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
RequestOutput
|
The next RequestOutput to merge. |
required |
|
bool
|
Whether to aggregate metrics. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
encrypt
¶
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
¶
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.