Skip to content

parsers

Disable server-side tool/reasoning parsing under Output Protection (OP) Encryption.

vLLM's tool and reasoning parsers run after the OP plugin has encrypted the model output, so they would parse ciphertext. That fails to extract anything useful and, for several reasoning parsers, actively misroutes the entire encrypted payload into reasoning_content while leaving content empty (which is then dropped when include_reasoning is False).

Output Protection delegates tool/reasoning parsing to the client, which holds the shared key, decrypts the content, and runs the matching parser locally on the plaintext.

This module patches ParserManager.get_parser so the parser it returns leaves the (encrypted) output untouched. The ciphertext flows through verbatim as content, while still inheriting everything else (adjust_request, tool_parser_cls, reasoning_parser_cls, ...) so vLLM keeps guiding generation (tool-call grammar / reasoning setup).

Under almost no circumstances should you need to import this module directly. If stainedglass_output_protection is installed, and you launch vLLM via the alternative entrypoint, this module will be automatically applied.

Functions:

Name Description
patch_parser_manager

Patch ParserManager.get_parser to return passthrough parsers.

wrap_parser_cls

Return a passthrough subclass of base_cls.

patch_parser_manager

patch_parser_manager() -> None

Patch ParserManager.get_parser to return passthrough parsers.

wrap_parser_cls

wrap_parser_cls(
    base_cls: type[ParserT] | None,
) -> type[ParserT] | None
wrap_parser_cls(
    base_cls: type[ParserT] | None,
) -> type[ParserT] | None
wrap_parser_cls(
    base_cls: type[ParserT] | None,
) -> type[ParserT] | None

Return a passthrough subclass of base_cls.

The result is a subclass of base_cls (so callers keep its type and class surface) that also mixes in _PassthroughParserMixin. Memoized so each base class maps to a single wrapper class. Returns base_cls unchanged if it is None or already a passthrough subclass (never double-wraps).

Parameters:

Name Type Description Default

base_cls

type[ParserT] | None

The parser class returned by ParserManager.get_parser, or None.

required

Returns:

Type Description
type[ParserT] | None

A passthrough subclass of base_cls, or base_cls/None when there is

type[ParserT] | None

nothing to wrap.