Version answer display instructions and restrict unsupported payloads (#60904)

## What changed

- Replace free-form `AgentMessageDisplay` actions with a version `1` contract using `show`, `hide`, and `block` modes, with typed annotations, replacements, block reasons, and trusted-contact handling.
- Discard invalid or unsupported display instructions and set `moderated` to `true` when reading moderation data in Rust and the Python SDK.
- Update generated JSON schemas, TypeScript types, and Python SDK models to match the contract.

## Testing

Add coverage for display variants, tolerance of extra fields, and unsupported-version or unknown-mode fallback. Update the final-answer moderation test and add Python coverage for thread history and item notifications.

GitOrigin-RevId: ec64070002da67e8e377dccb3728806ac8b290e7
This commit is contained in:
psachdeva-oai
2026-11-11 23:35:05 +00:00
committed by copyberry
parent 9248df5978
commit 8a4b226ad5
39 changed files with 4261 additions and 643 deletions
@@ -12,35 +12,100 @@
"type": "string"
},
"AgentMessageDisplay": {
"description": "A presentation instruction for Chat to apply to this answer when recovering history.",
"properties": {
"action": {
"description": "Unknown actions must be left for the producing client to handle.",
"type": "string"
"description": "How Chat should present a recovered answer.",
"oneOf": [
{
"properties": {
"annotation": {
"anyOf": [
{
"$ref": "#/definitions/AnswerAnnotation"
},
{
"type": "null"
}
]
},
"mode": {
"enum": [
"show"
],
"type": "string"
},
"trustedContacts": {
"$ref": "#/definitions/TrustedContacts"
},
"version": {
"enum": [
1
],
"format": "uint8",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"mode",
"trustedContacts",
"version"
],
"type": "object"
},
"blockType": {
"type": [
"string",
"null"
]
{
"properties": {
"mode": {
"enum": [
"hide"
],
"type": "string"
},
"replacement": {
"$ref": "#/definitions/AnswerReplacement"
},
"version": {
"enum": [
1
],
"format": "uint8",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"mode",
"replacement",
"version"
],
"type": "object"
},
"checkTrustedContacts": {
"type": [
"boolean",
"null"
]
},
"cyberTrustedAccess": {
"type": [
"boolean",
"null"
]
{
"properties": {
"mode": {
"enum": [
"block"
],
"type": "string"
},
"reason": {
"$ref": "#/definitions/BlockReason"
},
"version": {
"enum": [
1
],
"format": "uint8",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"mode",
"reason",
"version"
],
"type": "object"
}
},
"required": [
"action"
],
"type": "object"
]
},
"AgentMessageModeration": {
"properties": {
@@ -66,6 +131,47 @@
"AgentPath": {
"type": "string"
},
"AnswerAnnotation": {
"oneOf": [
{
"properties": {
"kind": {
"enum": [
"wellbeingHelpline"
],
"type": "string"
},
"subject": {
"$ref": "#/definitions/HelplineSubject"
}
},
"required": [
"kind",
"subject"
],
"type": "object"
}
]
},
"AnswerReplacement": {
"oneOf": [
{
"properties": {
"kind": {
"enum": [
"wellbeingPromptHelpline"
],
"type": "string"
}
},
"required": [
"kind"
],
"title": "WellbeingPromptHelplineAnswerReplacement",
"type": "object"
}
]
},
"AsyncUserInputQuestion": {
"additionalProperties": false,
"properties": {
@@ -87,6 +193,50 @@
],
"type": "object"
},
"BlockReason": {
"oneOf": [
{
"properties": {
"kind": {
"enum": [
"protection"
],
"type": "string"
},
"protectionType": {
"description": "Identifies the same moderation row that Chat writes on the live path.",
"type": "string"
}
},
"required": [
"kind",
"protectionType"
],
"type": "object"
},
{
"properties": {
"kind": {
"enum": [
"cyber"
],
"type": "string"
},
"trustedAccess": {
"type": [
"boolean",
"null"
]
}
},
"required": [
"kind"
],
"title": "KindBlockReason",
"type": "object"
}
]
},
"ByteRange": {
"properties": {
"end": {
@@ -710,6 +860,13 @@
},
"type": "object"
},
"HelplineSubject": {
"enum": [
"answer",
"prompt"
],
"type": "string"
},
"HookPromptFragment": {
"properties": {
"hookRunId": {
@@ -2560,6 +2717,13 @@
}
]
},
"TrustedContacts": {
"enum": [
"check",
"skip"
],
"type": "string"
},
"Turn": {
"properties": {
"completedAt": {