Add opt-in output token replay for OpenAI requests (#52742)

## What changed

- Add the disabled-by-default `output_token_replay` feature to request `output.encrypted_content` from OpenAI providers.
- Preserve encrypted message and tool-call output, message and function-call status, and output-text `annotations` and `logprobs` through history and replay. Update the generated protocol schemas and SDK types.
- Strip output ciphertext from requests to other providers while retaining it in stored history, including after replay is disabled. Remove encrypted content from memory extraction inputs.

## Testing

Add integration coverage for the feature/provider combinations, metadata replay across follow-up requests, and history preservation when resuming with replay disabled.

GitOrigin-RevId: 77729a021b6771933402aebe74ece8eb39c057e2
This commit is contained in:
pakrym-oai
2026-10-10 01:25:00 +00:00
committed by copyberry
parent e4490eff65
commit 5ef96ab278
119 changed files with 1602 additions and 91 deletions
@@ -1128,6 +1128,8 @@ class OutputTextContentItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
annotations: list | None = None
logprobs: list | None = None
text: str
type: Annotated[Literal["output_text"], Field(title="OutputTextContentItemType")]
@@ -3993,6 +3995,7 @@ class LocalShellCallResponseItem(BaseModel):
)
action: LocalShellAction
call_id: Annotated[str | None, Field(description="Set when using the Responses API.")] = None
encrypted_content: str | None = None
id: Annotated[
str | None,
Field(description="Legacy id field retained for compatibility with older payloads."),
@@ -4008,11 +4011,13 @@ class FunctionCallResponseItem(BaseModel):
)
arguments: str
call_id: str
encrypted_content: str | None = None
encrypted_function_args: list[str] | None = None
id: str | None = None
internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
name: str
namespace: str | None = None
status: str | None = None
type: Annotated[Literal["function_call"], Field(title="FunctionCallResponseItemType")]
@@ -4022,6 +4027,7 @@ class ToolSearchCallResponseItem(BaseModel):
)
arguments: Any
call_id: str | None = None
encrypted_content: str | None = None
execution: str
id: str | None = None
internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
@@ -4034,6 +4040,7 @@ class CustomToolCallResponseItem(BaseModel):
populate_by_name=True,
)
call_id: str
encrypted_content: str | None = None
id: str | None = None
input: str
internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
@@ -4060,6 +4067,7 @@ class ImageGenerationCallResponseItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
encrypted_content: str | None = None
id: str | None = None
internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
result: str
@@ -9145,10 +9153,12 @@ class MessageResponseItem(BaseModel):
populate_by_name=True,
)
content: list[ContentItem]
encrypted_content: str | None = None
id: str | None = None
internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
phase: MessagePhase | None = None
role: str
status: str | None = None
type: Annotated[Literal["message"], Field(title="MessageResponseItemType")]
@@ -9157,6 +9167,7 @@ class WebSearchCallResponseItem(BaseModel):
populate_by_name=True,
)
action: ResponsesApiWebSearchAction | None = None
encrypted_content: str | None = None
id: str | None = None
internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
status: str | None = None