core: rename metadata -> internal_chat_message_metadata_passthrough (#28968)

## Description
This PR cuts Codex over from generic `ResponseItem.metadata` (introduced
here: https://github.com/openai/codex/pull/28355) to
`ResponseItem.internal_chat_message_metadata_passthrough`, which is the
blessed path and has strongly-typed keys.

For now we have to drop this MAv2 usage of `metadata`:
https://github.com/openai/codex/pull/28561 until we figure out where
that should live.
This commit is contained in:
Owen Lin
2026-06-22 11:11:25 -07:00
committed by GitHub
parent 9f06cf1a09
commit 5b95745eae
77 changed files with 866 additions and 797 deletions
+42 -47
View File
@@ -1315,6 +1315,18 @@
],
"type": "object"
},
"InternalChatMessageMetadataPassthrough": {
"description": "Internal Responses API passthrough metadata copied into underlying chat messages.\n\nResponses API strongly types this payload. Do not modify it without first getting API approval and making the corresponding Responses API change.",
"properties": {
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"LegacyAppPathString": {
"type": "string"
},
@@ -2302,10 +2314,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2358,10 +2370,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2412,10 +2424,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2462,10 +2474,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2505,10 +2517,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2559,10 +2571,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2602,10 +2614,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2645,10 +2657,10 @@
"input": {
"type": "string"
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2692,10 +2704,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2744,10 +2756,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2796,10 +2808,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2834,10 +2846,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2883,10 +2895,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2910,10 +2922,10 @@
},
{
"properties": {
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2948,10 +2960,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -2990,23 +3002,6 @@
}
]
},
"ResponseItemMetadata": {
"properties": {
"source_call_id": {
"type": [
"string",
"null"
]
},
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"ResponsesApiWebSearchAction": {
"oneOf": [
{
@@ -11145,6 +11145,18 @@
}
]
},
"InternalChatMessageMetadataPassthrough": {
"description": "Internal Responses API passthrough metadata copied into underlying chat messages.\n\nResponses API strongly types this payload. Do not modify it without first getting API approval and making the corresponding Responses API change.",
"properties": {
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"ItemCompletedNotification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
@@ -14948,10 +14960,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15004,10 +15016,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15058,10 +15070,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15108,10 +15120,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15151,10 +15163,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15205,10 +15217,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15248,10 +15260,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15291,10 +15303,10 @@
"input": {
"type": "string"
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15338,10 +15350,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15390,10 +15402,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15442,10 +15454,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15480,10 +15492,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15529,10 +15541,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15556,10 +15568,10 @@
},
{
"properties": {
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15594,10 +15606,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/v2/ResponseItemMetadata"
"$ref": "#/definitions/v2/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -15636,23 +15648,6 @@
}
]
},
"ResponseItemMetadata": {
"properties": {
"source_call_id": {
"type": [
"string",
"null"
]
},
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"ResponsesApiWebSearchAction": {
"oneOf": [
{
@@ -7549,6 +7549,18 @@
}
]
},
"InternalChatMessageMetadataPassthrough": {
"description": "Internal Responses API passthrough metadata copied into underlying chat messages.\n\nResponses API strongly types this payload. Do not modify it without first getting API approval and making the corresponding Responses API change.",
"properties": {
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"ItemCompletedNotification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
@@ -11352,10 +11364,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11408,10 +11420,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11462,10 +11474,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11512,10 +11524,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11555,10 +11567,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11609,10 +11621,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11652,10 +11664,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11695,10 +11707,10 @@
"input": {
"type": "string"
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11742,10 +11754,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11794,10 +11806,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11846,10 +11858,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11884,10 +11896,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11933,10 +11945,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11960,10 +11972,10 @@
},
{
"properties": {
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -11998,10 +12010,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -12040,23 +12052,6 @@
}
]
},
"ResponseItemMetadata": {
"properties": {
"source_call_id": {
"type": [
"string",
"null"
]
},
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"ResponsesApiWebSearchAction": {
"oneOf": [
{
@@ -216,6 +216,18 @@
],
"type": "string"
},
"InternalChatMessageMetadataPassthrough": {
"description": "Internal Responses API passthrough metadata copied into underlying chat messages.\n\nResponses API strongly types this payload. Do not modify it without first getting API approval and making the corresponding Responses API change.",
"properties": {
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"LocalShellAction": {
"oneOf": [
{
@@ -383,10 +395,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -439,10 +451,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -493,10 +505,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -543,10 +555,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -586,10 +598,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -640,10 +652,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -683,10 +695,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -726,10 +738,10 @@
"input": {
"type": "string"
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -773,10 +785,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -825,10 +837,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -877,10 +889,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -915,10 +927,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -964,10 +976,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -991,10 +1003,10 @@
},
{
"properties": {
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -1029,10 +1041,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -1071,23 +1083,6 @@
}
]
},
"ResponseItemMetadata": {
"properties": {
"source_call_id": {
"type": [
"string",
"null"
]
},
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"ResponsesApiWebSearchAction": {
"oneOf": [
{
@@ -279,6 +279,18 @@
],
"type": "string"
},
"InternalChatMessageMetadataPassthrough": {
"description": "Internal Responses API passthrough metadata copied into underlying chat messages.\n\nResponses API strongly types this payload. Do not modify it without first getting API approval and making the corresponding Responses API change.",
"properties": {
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"LocalShellAction": {
"oneOf": [
{
@@ -454,10 +466,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -510,10 +522,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -564,10 +576,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -614,10 +626,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -657,10 +669,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -711,10 +723,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -754,10 +766,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -797,10 +809,10 @@
"input": {
"type": "string"
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -844,10 +856,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -896,10 +908,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -948,10 +960,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -986,10 +998,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -1035,10 +1047,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -1062,10 +1074,10 @@
},
{
"properties": {
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -1100,10 +1112,10 @@
"null"
]
},
"metadata": {
"internal_chat_message_metadata_passthrough": {
"anyOf": [
{
"$ref": "#/definitions/ResponseItemMetadata"
"$ref": "#/definitions/InternalChatMessageMetadataPassthrough"
},
{
"type": "null"
@@ -1142,23 +1154,6 @@
}
]
},
"ResponseItemMetadata": {
"properties": {
"source_call_id": {
"type": [
"string",
"null"
]
},
"turn_id": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"ResponsesApiWebSearchAction": {
"oneOf": [
{
@@ -0,0 +1,11 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* Internal Responses API passthrough metadata copied into underlying chat messages.
*
* Responses API strongly types this payload. Do not modify it without first getting API
* approval and making the corresponding Responses API change.
*/
export type InternalChatMessageMetadataPassthrough = { turn_id?: string, };
@@ -4,15 +4,15 @@
import type { AgentMessageInputContent } from "./AgentMessageInputContent";
import type { ContentItem } from "./ContentItem";
import type { FunctionCallOutputBody } from "./FunctionCallOutputBody";
import type { InternalChatMessageMetadataPassthrough } from "./InternalChatMessageMetadataPassthrough";
import type { LocalShellAction } from "./LocalShellAction";
import type { LocalShellStatus } from "./LocalShellStatus";
import type { MessagePhase } from "./MessagePhase";
import type { ReasoningItemContent } from "./ReasoningItemContent";
import type { ReasoningItemReasoningSummary } from "./ReasoningItemReasoningSummary";
import type { ResponseItemMetadata } from "./ResponseItemMetadata";
import type { WebSearchAction } from "./WebSearchAction";
export type ResponseItem = { "type": "message", id?: string, role: string, content: Array<ContentItem>, phase?: MessagePhase, metadata?: ResponseItemMetadata, } | { "type": "agent_message", id?: string, author: string, recipient: string, content: Array<AgentMessageInputContent>, metadata?: ResponseItemMetadata, } | { "type": "reasoning", id?: string, summary: Array<ReasoningItemReasoningSummary>, content?: Array<ReasoningItemContent>, encrypted_content: string | null, metadata?: ResponseItemMetadata, } | { "type": "local_shell_call",
export type ResponseItem = { "type": "message", id?: string, role: string, content: Array<ContentItem>, phase?: MessagePhase, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "agent_message", id?: string, author: string, recipient: string, content: Array<AgentMessageInputContent>, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "reasoning", id?: string, summary: Array<ReasoningItemReasoningSummary>, content?: Array<ReasoningItemContent>, encrypted_content: string | null, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "local_shell_call",
/**
* Legacy id field retained for compatibility with older payloads.
*/
@@ -20,4 +20,4 @@ id?: string,
/**
* Set when using the Responses API.
*/
call_id: string | null, status: LocalShellStatus, action: LocalShellAction, metadata?: ResponseItemMetadata, } | { "type": "function_call", id?: string, name: string, namespace?: string, arguments: string, call_id: string, metadata?: ResponseItemMetadata, } | { "type": "tool_search_call", id?: string, call_id: string | null, status?: string, execution: string, arguments: unknown, metadata?: ResponseItemMetadata, } | { "type": "function_call_output", id?: string, call_id: string, output: FunctionCallOutputBody, metadata?: ResponseItemMetadata, } | { "type": "custom_tool_call", id?: string, status?: string, call_id: string, name: string, input: string, metadata?: ResponseItemMetadata, } | { "type": "custom_tool_call_output", id?: string, call_id: string, name?: string, output: FunctionCallOutputBody, metadata?: ResponseItemMetadata, } | { "type": "tool_search_output", id?: string, call_id: string | null, status: string, execution: string, tools: unknown[], metadata?: ResponseItemMetadata, } | { "type": "web_search_call", id?: string, status?: string, action?: WebSearchAction, metadata?: ResponseItemMetadata, } | { "type": "image_generation_call", id?: string, status: string, revised_prompt?: string, result: string, metadata?: ResponseItemMetadata, } | { "type": "compaction", id?: string, encrypted_content: string, metadata?: ResponseItemMetadata, } | { "type": "compaction_trigger", metadata?: ResponseItemMetadata, } | { "type": "context_compaction", id?: string, encrypted_content?: string, metadata?: ResponseItemMetadata, } | { "type": "other" };
call_id: string | null, status: LocalShellStatus, action: LocalShellAction, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "function_call", id?: string, name: string, namespace?: string, arguments: string, call_id: string, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "tool_search_call", id?: string, call_id: string | null, status?: string, execution: string, arguments: unknown, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "function_call_output", id?: string, call_id: string, output: FunctionCallOutputBody, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "custom_tool_call", id?: string, status?: string, call_id: string, name: string, input: string, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "custom_tool_call_output", id?: string, call_id: string, name?: string, output: FunctionCallOutputBody, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "tool_search_output", id?: string, call_id: string | null, status: string, execution: string, tools: unknown[], internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "web_search_call", id?: string, status?: string, action?: WebSearchAction, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "image_generation_call", id?: string, status: string, revised_prompt?: string, result: string, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "compaction", id?: string, encrypted_content: string, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "compaction_trigger", internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "context_compaction", id?: string, encrypted_content?: string, internal_chat_message_metadata_passthrough?: InternalChatMessageMetadataPassthrough, } | { "type": "other" };
@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ResponseItemMetadata = { turn_id?: string, source_call_id?: string, };
+1 -1
View File
@@ -41,6 +41,7 @@ export type { InitializeCapabilities } from "./InitializeCapabilities";
export type { InitializeParams } from "./InitializeParams";
export type { InitializeResponse } from "./InitializeResponse";
export type { InputModality } from "./InputModality";
export type { InternalChatMessageMetadataPassthrough } from "./InternalChatMessageMetadataPassthrough";
export type { InternalSessionSource } from "./InternalSessionSource";
export type { LegacyAppPathString } from "./LegacyAppPathString";
export type { LocalShellAction } from "./LocalShellAction";
@@ -68,7 +69,6 @@ export type { Resource } from "./Resource";
export type { ResourceContent } from "./ResourceContent";
export type { ResourceTemplate } from "./ResourceTemplate";
export type { ResponseItem } from "./ResponseItem";
export type { ResponseItemMetadata } from "./ResponseItemMetadata";
export type { ReviewDecision } from "./ReviewDecision";
export type { ServerNotification } from "./ServerNotification";
export type { ServerRequest } from "./ServerRequest";
@@ -3775,7 +3775,7 @@ mod tests {
text: "plain text".into(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
RolloutItem::EventMsg(EventMsg::TurnComplete(TurnCompleteEvent {
turn_id: "turn-a".into(),
@@ -134,12 +134,12 @@ async fn auto_compaction_remote_emits_started_and_completed_items() -> Result<()
text: "REMOTE_COMPACT_SUMMARY".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let compact_mock = responses::mount_compact_json_once(
@@ -60,7 +60,7 @@ async fn thread_inject_items_adds_raw_response_items_to_thread_history() -> Resu
text: injected_text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let inject_req = mcp
@@ -198,7 +198,7 @@ async fn thread_inject_items_adds_raw_response_items_after_a_turn() -> Result<()
text: "Injected after first turn".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let injected_value = serde_json::to_value(&injected_item)?;
@@ -2589,7 +2589,7 @@ async fn thread_resume_rejects_history_when_thread_is_running() -> Result<()> {
text: "history override".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]),
..Default::default()
})
@@ -3598,7 +3598,7 @@ async fn thread_resume_supports_history_and_overrides() -> Result<()> {
text: history_text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
// Resume with explicit history and override the model.
@@ -825,7 +825,7 @@ mod tests {
text: "hello".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
tools: vec![json!({
"type": "function",
+1 -1
View File
@@ -162,7 +162,7 @@ mod tests {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}])),
commands: Some(SearchCommands {
search_query: Some(vec![SearchQuery {
+2 -2
View File
@@ -313,7 +313,7 @@ async fn responses_client_stream_request_preserves_item_ids() -> Result<()> {
role: "user".into(),
content: vec![ContentItem::InputText { text: "hi".into() }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
tools: Vec::new(),
tool_choice: "auto".into(),
@@ -518,7 +518,7 @@ async fn azure_store_sends_ids_and_headers() -> Result<()> {
role: "user".into(),
content: vec![ContentItem::InputText { text: "hi".into() }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
tools: Vec::new(),
tool_choice: "auto".into(),
+2 -2
View File
@@ -83,7 +83,7 @@ pub trait ContextualUserFragment {
text: self.render(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -95,7 +95,7 @@ pub trait ContextualUserFragment {
text: self.render(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+11 -11
View File
@@ -72,7 +72,7 @@ fn assistant_message(text: &str, phase: Option<MessagePhase>) -> ResponseItem {
text: text.to_string(),
}],
phase,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -92,7 +92,7 @@ fn spawn_agent_call(call_id: &str) -> ResponseItem {
namespace: None,
arguments: "{}".to_string(),
call_id: call_id.to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -909,7 +909,7 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
text: "Parent root guidance.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -918,7 +918,7 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
text: "Parent subagent guidance.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
assistant_message("parent commentary", Some(MessagePhase::Commentary)),
assistant_message("parent final answer", Some(MessagePhase::FinalAnswer)),
@@ -928,7 +928,7 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
summary: Vec::new(),
content: None,
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
trigger_message.to_response_input_item().into(),
spawn_agent_call(&parent_spawn_call_id),
@@ -996,7 +996,7 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
text: "parent seed context".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
assistant_message("parent final answer", Some(MessagePhase::FinalAnswer)),
ResponseItem::Message {
@@ -1006,7 +1006,7 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
text: "Child subagent guidance.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
assert_eq!(
@@ -1125,7 +1125,7 @@ async fn spawn_agent_fork_strips_parent_usage_hints_from_compacted_history() {
text: "compacted parent summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -1134,7 +1134,7 @@ async fn spawn_agent_fork_strips_parent_usage_hints_from_compacted_history() {
text: "Parent root guidance.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
parent_thread
@@ -1449,7 +1449,7 @@ async fn spawn_agent_fork_last_n_turns_drops_parent_startup_prefix_when_under_li
text: "parent startup developer context".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
)
.await;
@@ -1571,7 +1571,7 @@ async fn spawn_agent_fork_last_n_turns_strips_parent_usage_hints() {
text: "Parent root guidance.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
spawn_agent_call(&parent_spawn_call_id),
],
+4 -2
View File
@@ -781,7 +781,9 @@ impl ModelClient {
let instructions = &prompt.base_instructions.text;
let mut input = prompt.get_formatted_input_for_request(model_info.use_responses_lite);
if !self.state.provider.info().is_openai() {
input.iter_mut().for_each(ResponseItem::clear_metadata);
input
.iter_mut()
.for_each(ResponseItem::clear_internal_chat_message_metadata_passthrough);
}
let tools = create_tools_json_for_responses_api(&prompt.tools)?;
let reasoning = Self::build_reasoning(model_info, effort, summary);
@@ -1072,7 +1074,7 @@ impl ModelClientSession {
if !self.client.state.provider.info().is_openai() {
response_items
.iter_mut()
.for_each(ResponseItem::clear_metadata);
.for_each(ResponseItem::clear_internal_chat_message_metadata_passthrough);
}
let Some(incremental_items) = after_previous_input.strip_prefix(response_items.as_slice())
else {
+6 -6
View File
@@ -20,7 +20,7 @@ fn prompt_with_image_outputs() -> Prompt {
detail: Some(ImageDetail::Original),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
@@ -31,7 +31,7 @@ fn prompt_with_image_outputs() -> Prompt {
detail: Some(ImageDetail::High),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
@@ -43,7 +43,7 @@ fn prompt_with_image_outputs() -> Prompt {
detail: Some(ImageDetail::Auto),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
..Default::default()
@@ -68,7 +68,7 @@ fn responses_lite_request_copies_strip_image_details() {
detail: None,
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
@@ -79,7 +79,7 @@ fn responses_lite_request_copies_strip_image_details() {
detail: None,
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
@@ -91,7 +91,7 @@ fn responses_lite_request_copies_strip_image_details() {
detail: None,
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
+1 -1
View File
@@ -226,7 +226,7 @@ fn output_message(id: &str, text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+1 -1
View File
@@ -81,7 +81,7 @@ async fn forward_events_cancelled_while_send_blocked_shuts_down_delegate() {
call_id: "call-1".to_string(),
name: "tool".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
}),
})
+1 -1
View File
@@ -452,7 +452,7 @@ impl CodexThread {
role: "user".to_string(),
content: vec![ContentItem::InputText { text: message }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
self.codex
.session
+14 -7
View File
@@ -30,9 +30,9 @@ use codex_protocol::error::Result as CodexResult;
use codex_protocol::items::ContextCompactionItem;
use codex_protocol::items::TurnItem;
use codex_protocol::models::ContentItem;
use codex_protocol::models::InternalChatMessageMetadataPassthrough;
use codex_protocol::models::ResponseInputItem;
use codex_protocol::models::ResponseItem;
use codex_protocol::models::ResponseItemMetadata;
use codex_protocol::protocol::CompactedItem;
use codex_protocol::protocol::EventMsg;
use codex_protocol::protocol::TurnStartedEvent;
@@ -459,7 +459,7 @@ pub fn content_items_to_text(content: &[ContentItem]) -> Option<String> {
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct CompactedUserMessage {
message: String,
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
}
pub(crate) fn collect_user_messages(items: &[ResponseItem]) -> Vec<CompactedUserMessage> {
@@ -472,8 +472,11 @@ pub(crate) fn collect_user_messages(items: &[ResponseItem]) -> Vec<CompactedUser
} else {
Some(CompactedUserMessage {
message: user.message(),
metadata: match item {
ResponseItem::Message { metadata, .. } => metadata.clone(),
internal_chat_message_metadata_passthrough: match item {
ResponseItem::Message {
internal_chat_message_metadata_passthrough,
..
} => internal_chat_message_metadata_passthrough.clone(),
_ => None,
},
})
@@ -580,7 +583,9 @@ fn build_compacted_history_with_limit(
truncate_text(&message.message, TruncationPolicy::Tokens(remaining));
selected_messages.push(CompactedUserMessage {
message: truncated,
metadata: message.metadata.clone(),
internal_chat_message_metadata_passthrough: message
.internal_chat_message_metadata_passthrough
.clone(),
});
break;
}
@@ -596,7 +601,9 @@ fn build_compacted_history_with_limit(
text: message.message.clone(),
}],
phase: None,
metadata: message.metadata.clone(),
internal_chat_message_metadata_passthrough: message
.internal_chat_message_metadata_passthrough
.clone(),
});
}
@@ -611,7 +618,7 @@ fn build_compacted_history_with_limit(
role: "user".to_string(),
content: vec![ContentItem::InputText { text: summary_text }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
history
+6 -6
View File
@@ -414,31 +414,31 @@ fn rewritten_output_for_context_window(item: &ResponseItem) -> Option<ResponseIt
id,
call_id,
output,
metadata,
internal_chat_message_metadata_passthrough: metadata,
} => ResponseItem::FunctionCallOutput {
id: id.clone(),
call_id: call_id.clone(),
output: truncated_output_payload(output),
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
},
ResponseItem::CustomToolCallOutput {
id,
call_id,
name,
output,
metadata,
internal_chat_message_metadata_passthrough: metadata,
} => ResponseItem::CustomToolCallOutput {
id: id.clone(),
call_id: call_id.clone(),
name: name.clone(),
output: truncated_output_payload(output),
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
},
ResponseItem::ToolSearchOutput {
call_id,
status,
execution,
metadata,
internal_chat_message_metadata_passthrough: metadata,
..
} => ResponseItem::ToolSearchOutput {
id: item.id().map(str::to_string),
@@ -446,7 +446,7 @@ fn rewritten_output_for_context_window(item: &ResponseItem) -> Option<ResponseIt
status: status.clone(),
execution: execution.clone(),
tools: Vec::new(),
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
},
_ => return None,
})
+17 -15
View File
@@ -234,7 +234,9 @@ async fn run_remote_compact_task_inner_impl(
)
.await?;
let mut input = prompt_input.clone();
input.push(ResponseItem::CompactionTrigger { metadata: None });
input.push(ResponseItem::CompactionTrigger {
internal_chat_message_metadata_passthrough: None,
});
let prompt = Prompt {
input,
tools: tool_router.model_visible_specs(),
@@ -526,7 +528,7 @@ fn truncate_message_text_to_token_budget(
role,
content,
phase,
metadata,
internal_chat_message_metadata_passthrough: metadata,
} = item
else {
return Some(item);
@@ -565,7 +567,7 @@ fn truncate_message_text_to_token_budget(
role,
content: truncated_content,
phase,
metadata,
internal_chat_message_metadata_passthrough: metadata,
})
}
@@ -586,7 +588,7 @@ mod tests {
text: text.to_string(),
}],
phase,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -618,18 +620,18 @@ mod tests {
namespace: None,
arguments: "{}".to_string(),
call_id: "call_1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Compaction {
id: None,
encrypted_content: "old".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let output = ResponseItem::Compaction {
id: None,
encrypted_content: "new".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let (history, _) = build_v2_compacted_history(&input, output.clone());
@@ -658,7 +660,7 @@ mod tests {
let output = ResponseItem::Compaction {
id: None,
encrypted_content: "new".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let (history, _) = build_v2_compacted_history(&input, output.clone());
@@ -685,12 +687,12 @@ mod tests {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let output = ResponseItem::Compaction {
id: None,
encrypted_content: "new".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let (_, retained_image_count) = build_v2_compacted_history(&input, output);
@@ -738,7 +740,7 @@ mod tests {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let truncated =
@@ -762,7 +764,7 @@ mod tests {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]
);
}
@@ -777,7 +779,7 @@ mod tests {
detail: None,
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let newest = message("user", "new", /*phase*/ None);
let retained = vec![
@@ -802,7 +804,7 @@ mod tests {
detail: None,
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let newest = message("user", "new", /*phase*/ None);
let retained = vec![image_only_message, newest.clone()];
@@ -818,7 +820,7 @@ mod tests {
let compaction = ResponseItem::Compaction {
id: None,
encrypted_content: "encrypted".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let stream = response_stream(vec![
Ok(ResponseEvent::OutputItemDone(message(
+46 -45
View File
@@ -2,7 +2,7 @@ use super::*;
use codex_model_provider_info::ModelProviderInfo;
use codex_model_provider_info::WireApi;
use codex_protocol::models::DEFAULT_IMAGE_DETAIL;
use codex_protocol::models::ResponseItemMetadata;
use codex_protocol::models::InternalChatMessageMetadataPassthrough;
use pretty_assertions::assert_eq;
async fn process_compacted_history_with_test_session(
@@ -32,14 +32,14 @@ fn user_message(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
fn compacted_user_message(text: &str) -> CompactedUserMessage {
CompactedUserMessage {
message: text.to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -84,7 +84,7 @@ fn collect_user_messages_extracts_user_text_only() {
text: "ignored".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: Some("user".to_string()),
@@ -93,7 +93,7 @@ fn collect_user_messages_extracts_user_text_only() {
text: "first".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Other,
];
@@ -118,7 +118,7 @@ do things
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -127,7 +127,7 @@ do things
text: "<ENVIRONMENT_CONTEXT>cwd=/tmp</ENVIRONMENT_CONTEXT>".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -136,7 +136,7 @@ do things
text: "real user message".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -231,15 +231,16 @@ fn build_token_limited_compacted_history_appends_summary_message() {
}
#[test]
fn build_compacted_history_preserves_user_message_metadata() {
fn build_compacted_history_preserves_user_message_passthrough_metadata() {
let history = build_compacted_history(
Vec::new(),
&[CompactedUserMessage {
message: "first user message".to_string(),
metadata: Some(ResponseItemMetadata {
turn_id: Some("turn-1".to_string()),
..Default::default()
}),
internal_chat_message_metadata_passthrough: Some(
InternalChatMessageMetadataPassthrough {
turn_id: Some("turn-1".to_string()),
},
),
}],
"summary text",
);
@@ -282,7 +283,7 @@ async fn process_compacted_history_replaces_developer_messages() {
text: "stale permissions".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -291,7 +292,7 @@ async fn process_compacted_history_replaces_developer_messages() {
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -300,7 +301,7 @@ async fn process_compacted_history_replaces_developer_messages() {
text: "stale personality".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let (refreshed, mut expected) = process_compacted_history_with_test_session(
@@ -315,7 +316,7 @@ async fn process_compacted_history_replaces_developer_messages() {
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
assert_eq!(refreshed, expected);
}
@@ -329,7 +330,7 @@ async fn process_compacted_history_reinjects_full_initial_context() {
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let (refreshed, mut expected) = process_compacted_history_with_test_session(
compacted_history,
@@ -343,7 +344,7 @@ async fn process_compacted_history_reinjects_full_initial_context() {
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
assert_eq!(refreshed, expected);
}
@@ -363,7 +364,7 @@ keep me updated
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -376,7 +377,7 @@ keep me updated
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -389,7 +390,7 @@ keep me updated
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -398,7 +399,7 @@ keep me updated
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -407,7 +408,7 @@ keep me updated
text: "stale developer instructions".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let (refreshed, mut expected) = process_compacted_history_with_test_session(
@@ -422,7 +423,7 @@ keep me updated
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
assert_eq!(refreshed, expected);
}
@@ -462,7 +463,7 @@ async fn process_compacted_history_inserts_context_before_last_real_user_message
text: "older user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -471,7 +472,7 @@ async fn process_compacted_history_inserts_context_before_last_real_user_message
text: format!("{SUMMARY_PREFIX}\nsummary text"),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -480,7 +481,7 @@ async fn process_compacted_history_inserts_context_before_last_real_user_message
text: "latest user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -497,7 +498,7 @@ async fn process_compacted_history_inserts_context_before_last_real_user_message
text: "older user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -506,7 +507,7 @@ async fn process_compacted_history_inserts_context_before_last_real_user_message
text: format!("{SUMMARY_PREFIX}\nsummary text"),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
expected.extend(initial_context);
@@ -517,7 +518,7 @@ async fn process_compacted_history_inserts_context_before_last_real_user_message
text: "latest user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
assert_eq!(refreshed, expected);
}
@@ -531,7 +532,7 @@ async fn process_compacted_history_reinjects_model_switch_message() {
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let previous_turn_settings = PreviousTurnSettings {
model: "previous-regular-model".to_string(),
@@ -562,7 +563,7 @@ async fn process_compacted_history_reinjects_model_switch_message() {
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
assert_eq!(refreshed, expected);
}
@@ -577,7 +578,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: "older user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -586,7 +587,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: "latest user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -595,7 +596,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: format!("{SUMMARY_PREFIX}\nsummary text"),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let initial_context = vec![ResponseItem::Message {
@@ -605,7 +606,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: "fresh permissions".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let refreshed =
@@ -618,7 +619,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: "older user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -627,7 +628,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: "fresh permissions".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -636,7 +637,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: "latest user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -645,7 +646,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_summary_last()
text: format!("{SUMMARY_PREFIX}\nsummary text"),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
assert_eq!(refreshed, expected);
@@ -656,7 +657,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_compaction_last
let compacted_history = vec![ResponseItem::Compaction {
id: None,
encrypted_content: "encrypted".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let initial_context = vec![ResponseItem::Message {
id: None,
@@ -665,7 +666,7 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_compaction_last
text: "fresh permissions".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let refreshed =
@@ -678,12 +679,12 @@ fn insert_initial_context_before_last_real_user_or_summary_keeps_compaction_last
text: "fresh permissions".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Compaction {
id: None,
encrypted_content: "encrypted".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
assert_eq!(refreshed, expected);
+4 -4
View File
@@ -359,25 +359,25 @@ impl ContextManager {
id,
call_id,
output,
metadata,
internal_chat_message_metadata_passthrough: metadata,
} => ResponseItem::FunctionCallOutput {
id: id.clone(),
call_id: call_id.clone(),
output: truncate_function_output_payload(output, policy_with_serialization_budget),
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
},
ResponseItem::CustomToolCallOutput {
id,
call_id,
name,
output,
metadata,
internal_chat_message_metadata_passthrough: metadata,
} => ResponseItem::CustomToolCallOutput {
id: id.clone(),
call_id: call_id.clone(),
name: name.clone(),
output: truncate_function_output_payload(output, policy_with_serialization_budget),
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
},
ResponseItem::Message { .. }
| ResponseItem::AgentMessage { .. }
+103 -104
View File
@@ -10,12 +10,12 @@ use codex_protocol::models::FunctionCallOutputBody;
use codex_protocol::models::FunctionCallOutputContentItem;
use codex_protocol::models::FunctionCallOutputPayload;
use codex_protocol::models::ImageDetail;
use codex_protocol::models::InternalChatMessageMetadataPassthrough;
use codex_protocol::models::LocalShellAction;
use codex_protocol::models::LocalShellExecAction;
use codex_protocol::models::LocalShellStatus;
use codex_protocol::models::ReasoningItemContent;
use codex_protocol::models::ReasoningItemReasoningSummary;
use codex_protocol::models::ResponseItemMetadata;
use codex_protocol::openai_models::InputModality;
use codex_protocol::openai_models::default_input_modalities;
use codex_protocol::protocol::AskForApproval;
@@ -43,7 +43,7 @@ fn assistant_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -62,7 +62,7 @@ fn inter_agent_assistant_msg(text: &str) -> ResponseItem {
text: serde_json::to_string(&communication).unwrap(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -96,7 +96,7 @@ fn user_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -108,7 +108,7 @@ fn user_input_text_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -120,7 +120,7 @@ fn developer_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -135,7 +135,7 @@ fn developer_msg_with_fragments(texts: &[&str]) -> ResponseItem {
})
.collect(),
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -174,7 +174,7 @@ fn custom_tool_call_output(call_id: &str, output: &str) -> ResponseItem {
call_id: call_id.to_string(),
name: None,
output: FunctionCallOutputPayload::from_text(output.to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -188,7 +188,7 @@ fn reasoning_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}]),
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -200,7 +200,7 @@ fn reasoning_with_encrypted_content(len: usize) -> ResponseItem {
}],
content: None,
encrypted_content: Some("a".repeat(len)),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -224,7 +224,7 @@ fn filters_non_api_messages() {
text: "ignored".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let reasoning = reasoning_msg("thinking...");
h.record_items([&system, &reasoning, &ResponseItem::Other], policy);
@@ -247,7 +247,7 @@ fn filters_non_api_messages() {
text: "thinking...".to_string(),
}]),
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -256,7 +256,7 @@ fn filters_non_api_messages() {
text: "hi".to_string()
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -265,7 +265,7 @@ fn filters_non_api_messages() {
text: "hello".to_string()
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
]
);
@@ -415,7 +415,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -423,7 +423,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
@@ -437,7 +437,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
detail: Some(DEFAULT_IMAGE_DETAIL),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCall {
id: None,
@@ -445,7 +445,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
call_id: "tool-1".to_string(),
name: "js_repl".to_string(),
input: "view_image".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
@@ -460,7 +460,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
detail: Some(DEFAULT_IMAGE_DETAIL),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let history = create_history_with_items(items);
@@ -484,7 +484,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -492,7 +492,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
@@ -506,7 +506,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
.to_string(),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCall {
id: None,
@@ -514,7 +514,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
call_id: "tool-1".to_string(),
name: "js_repl".to_string(),
input: "view_image".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
@@ -529,7 +529,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
.to_string(),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
assert_eq!(stripped, expected);
@@ -549,7 +549,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]);
let preserved = with_images.for_prompt(&modalities);
assert_eq!(preserved.len(), 1);
@@ -569,7 +569,7 @@ fn for_prompt_preserves_image_generation_calls_when_images_are_supported() {
status: "generating".to_string(),
revised_prompt: Some("lobster".to_string()),
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -578,7 +578,7 @@ fn for_prompt_preserves_image_generation_calls_when_images_are_supported() {
text: "hi".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]);
@@ -590,7 +590,7 @@ fn for_prompt_preserves_image_generation_calls_when_images_are_supported() {
status: "generating".to_string(),
revised_prompt: Some("lobster".to_string()),
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -599,7 +599,7 @@ fn for_prompt_preserves_image_generation_calls_when_images_are_supported() {
text: "hi".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
]
);
@@ -615,14 +615,14 @@ fn for_prompt_clears_image_generation_result_when_images_are_unsupported() {
text: "generate a lobster".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::ImageGenerationCall {
id: Some("ig_123".to_string()),
status: "completed".to_string(),
revised_prompt: Some("lobster".to_string()),
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]);
@@ -636,14 +636,14 @@ fn for_prompt_clears_image_generation_result_when_images_are_unsupported() {
text: "generate a lobster".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::ImageGenerationCall {
id: Some("ig_123".to_string()),
status: "completed".to_string(),
revised_prompt: Some("lobster".to_string()),
result: String::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -680,13 +680,13 @@ fn remove_first_item_removes_matching_output_for_function_call() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "call-1".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let mut h = create_history_with_items(items);
@@ -701,7 +701,7 @@ fn remove_first_item_removes_matching_call_for_output() {
id: None,
call_id: "call-2".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -709,7 +709,7 @@ fn remove_first_item_removes_matching_call_for_output() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-2".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let mut h = create_history_with_items(items);
@@ -733,7 +733,7 @@ fn replace_last_turn_images_replaces_tool_output_images() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let mut history = create_history_with_items(items);
@@ -755,7 +755,7 @@ fn replace_last_turn_images_replaces_tool_output_images() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -771,7 +771,7 @@ fn replace_last_turn_images_does_not_touch_user_images() {
detail: Some(DEFAULT_IMAGE_DETAIL),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut history = create_history_with_items(items.clone());
@@ -793,13 +793,13 @@ fn remove_first_item_handles_local_shell_pair() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "call-3".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let mut h = create_history_with_items(items);
@@ -1022,14 +1022,14 @@ fn remove_first_item_handles_custom_tool_pair() {
call_id: "tool-1".to_string(),
name: "my_tool".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
call_id: "tool-1".to_string(),
name: None,
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let mut h = create_history_with_items(items);
@@ -1051,13 +1051,13 @@ fn normalization_retains_local_shell_outputs() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "shell-1".to_string(),
output: FunctionCallOutputPayload::from_text("Total output lines: 1\n\nok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -1082,9 +1082,8 @@ fn record_items_truncates_function_call_output_content() {
body: FunctionCallOutputBody::Text(long_output.clone()),
success: Some(true),
},
metadata: Some(ResponseItemMetadata {
internal_chat_message_metadata_passthrough: Some(InternalChatMessageMetadataPassthrough {
turn_id: Some("turn-1".to_string()),
..Default::default()
}),
};
@@ -1120,7 +1119,7 @@ fn record_items_truncates_custom_tool_call_output_content() {
call_id: "tool-200".to_string(),
name: None,
output: FunctionCallOutputPayload::from_text(long_output.clone()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
history.record_items([&item], policy);
@@ -1155,7 +1154,7 @@ fn record_items_respects_custom_token_limit() {
body: FunctionCallOutputBody::Text(long_output),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
history.record_items([&item], policy);
@@ -1275,7 +1274,7 @@ fn normalize_adds_missing_output_for_function_call() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-x".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1290,13 +1289,13 @@ fn normalize_adds_missing_output_for_function_call() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-x".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "call-x".to_string(),
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -1311,7 +1310,7 @@ fn normalize_adds_missing_output_for_custom_tool_call() {
call_id: "tool-x".to_string(),
name: "custom".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1326,14 +1325,14 @@ fn normalize_adds_missing_output_for_custom_tool_call() {
call_id: "tool-x".to_string(),
name: "custom".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
call_id: "tool-x".to_string(),
name: None,
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -1353,7 +1352,7 @@ fn normalize_adds_missing_output_for_local_shell_call_with_id() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1373,13 +1372,13 @@ fn normalize_adds_missing_output_for_local_shell_call_with_id() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "shell-1".to_string(),
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -1392,7 +1391,7 @@ fn normalize_removes_orphan_function_call_output() {
id: None,
call_id: "orphan-1".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1409,7 +1408,7 @@ fn normalize_removes_orphan_custom_tool_call_output() {
call_id: "orphan-2".to_string(),
name: None,
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1429,14 +1428,14 @@ fn normalize_mixed_inserts_and_removals() {
namespace: None,
arguments: "{}".to_string(),
call_id: "c1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
// Orphan output that should be removed
ResponseItem::FunctionCallOutput {
id: None,
call_id: "c2".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
// Will get an inserted custom tool output
ResponseItem::CustomToolCall {
@@ -1445,7 +1444,7 @@ fn normalize_mixed_inserts_and_removals() {
call_id: "t1".to_string(),
name: "tool".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
// Local shell call also gets an inserted function call output
ResponseItem::LocalShellCall {
@@ -1459,7 +1458,7 @@ fn normalize_mixed_inserts_and_removals() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let mut h = create_history_with_items(items);
@@ -1475,13 +1474,13 @@ fn normalize_mixed_inserts_and_removals() {
namespace: None,
arguments: "{}".to_string(),
call_id: "c1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "c1".to_string(),
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCall {
id: None,
@@ -1489,14 +1488,14 @@ fn normalize_mixed_inserts_and_removals() {
call_id: "t1".to_string(),
name: "tool".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
call_id: "t1".to_string(),
name: None,
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::LocalShellCall {
id: None,
@@ -1509,13 +1508,13 @@ fn normalize_mixed_inserts_and_removals() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "s1".to_string(),
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -1529,7 +1528,7 @@ fn normalize_adds_missing_output_for_function_call_inserts_output() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-x".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
h.normalize_history(&default_input_modalities());
@@ -1542,13 +1541,13 @@ fn normalize_adds_missing_output_for_function_call_inserts_output() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-x".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "call-x".to_string(),
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -1562,7 +1561,7 @@ fn normalize_adds_missing_output_for_tool_search_call() {
status: Some("completed".to_string()),
execution: "client".to_string(),
arguments: "{}".into(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1577,7 +1576,7 @@ fn normalize_adds_missing_output_for_tool_search_call() {
status: Some("completed".to_string()),
execution: "client".to_string(),
arguments: "{}".into(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::ToolSearchOutput {
id: None,
@@ -1585,7 +1584,7 @@ fn normalize_adds_missing_output_for_tool_search_call() {
status: "completed".to_string(),
execution: "client".to_string(),
tools: Vec::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
]
);
@@ -1601,7 +1600,7 @@ fn normalize_adds_missing_output_for_custom_tool_call_panics_in_debug() {
call_id: "tool-x".to_string(),
name: "custom".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
h.normalize_history(&default_input_modalities());
@@ -1622,7 +1621,7 @@ fn normalize_adds_missing_output_for_local_shell_call_with_id_panics_in_debug()
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
h.normalize_history(&default_input_modalities());
@@ -1636,7 +1635,7 @@ fn normalize_removes_orphan_function_call_output_panics_in_debug() {
id: None,
call_id: "orphan-1".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
h.normalize_history(&default_input_modalities());
@@ -1651,7 +1650,7 @@ fn normalize_removes_orphan_custom_tool_call_output_panics_in_debug() {
call_id: "orphan-2".to_string(),
name: None,
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
h.normalize_history(&default_input_modalities());
@@ -1666,7 +1665,7 @@ fn normalize_removes_orphan_client_tool_search_output() {
status: "completed".to_string(),
execution: "client".to_string(),
tools: Vec::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1685,7 +1684,7 @@ fn normalize_removes_orphan_client_tool_search_output_panics_in_debug() {
status: "completed".to_string(),
execution: "client".to_string(),
tools: Vec::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
h.normalize_history(&default_input_modalities());
@@ -1699,7 +1698,7 @@ fn normalize_keeps_server_tool_search_output_without_matching_call() {
status: "completed".to_string(),
execution: "server".to_string(),
tools: Vec::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut h = create_history_with_items(items);
@@ -1713,7 +1712,7 @@ fn normalize_keeps_server_tool_search_output_without_matching_call() {
status: "completed".to_string(),
execution: "server".to_string(),
tools: Vec::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]
);
}
@@ -1729,13 +1728,13 @@ fn normalize_mixed_inserts_and_removals_panics_in_debug() {
namespace: None,
arguments: "{}".to_string(),
call_id: "c1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "c2".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCall {
id: None,
@@ -1743,7 +1742,7 @@ fn normalize_mixed_inserts_and_removals_panics_in_debug() {
call_id: "t1".to_string(),
name: "tool".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::LocalShellCall {
id: None,
@@ -1756,7 +1755,7 @@ fn normalize_mixed_inserts_and_removals_panics_in_debug() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let mut h = create_history_with_items(items);
@@ -1780,7 +1779,7 @@ fn image_data_url_payload_does_not_dominate_message_estimate() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let text_only_item = ResponseItem::Message {
id: None,
@@ -1789,7 +1788,7 @@ fn image_data_url_payload_does_not_dominate_message_estimate() {
text: "Here is the screenshot".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&image_item).unwrap().len() as i64;
@@ -1818,7 +1817,7 @@ fn image_data_url_payload_does_not_dominate_function_call_output_estimate() {
detail: Some(DEFAULT_IMAGE_DETAIL),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -1846,7 +1845,7 @@ fn image_data_url_payload_does_not_dominate_custom_tool_call_output_estimate() {
detail: Some(DEFAULT_IMAGE_DETAIL),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -1867,7 +1866,7 @@ fn non_base64_image_urls_are_unchanged() {
detail: Some(DEFAULT_IMAGE_DETAIL),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let function_output_item = ResponseItem::FunctionCallOutput {
id: None,
@@ -1878,7 +1877,7 @@ fn non_base64_image_urls_are_unchanged() {
detail: Some(DEFAULT_IMAGE_DETAIL),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert_eq!(
@@ -1902,7 +1901,7 @@ fn encrypted_function_output_uses_plaintext_byte_estimate() {
encrypted_content: encrypted_content.clone(),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -1923,7 +1922,7 @@ fn data_url_without_base64_marker_is_unchanged() {
detail: Some(DEFAULT_IMAGE_DETAIL),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert_eq!(
@@ -1945,7 +1944,7 @@ fn non_image_base64_data_url_is_unchanged() {
detail: Some(DEFAULT_IMAGE_DETAIL),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -1966,7 +1965,7 @@ fn mixed_case_data_url_markers_are_adjusted() {
detail: Some(DEFAULT_IMAGE_DETAIL),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -1999,7 +1998,7 @@ fn multiple_inline_images_apply_multiple_fixed_costs() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -2034,7 +2033,7 @@ fn original_detail_images_scale_with_dimensions() {
detail: Some(ImageDetail::Original),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -2066,7 +2065,7 @@ fn original_detail_images_are_capped_at_max_patch_count() {
detail: Some(ImageDetail::Original),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -2101,7 +2100,7 @@ fn original_detail_webp_images_scale_with_dimensions() {
detail: Some(ImageDetail::Original),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let raw_len = serde_json::to_string(&item).unwrap().len() as i64;
@@ -2120,7 +2119,7 @@ fn text_only_items_unchanged() {
text: "Hello world, this is a response.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let estimated = estimate_response_item_model_visible_bytes(&item);
@@ -50,7 +50,7 @@ pub(crate) fn ensure_call_outputs_present(items: &mut Vec<ResponseItem>) {
id: None,
call_id: call_id.clone(),
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
));
}
@@ -67,7 +67,7 @@ pub(crate) fn ensure_call_outputs_present(items: &mut Vec<ResponseItem>) {
status: "completed".to_string(),
execution: "client".to_string(),
tools: Vec::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
));
}
@@ -84,7 +84,7 @@ pub(crate) fn ensure_call_outputs_present(items: &mut Vec<ResponseItem>) {
call_id: call_id.clone(),
name: None,
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
));
}
@@ -102,7 +102,7 @@ pub(crate) fn ensure_call_outputs_present(items: &mut Vec<ResponseItem>) {
id: None,
call_id: call_id.clone(),
output: FunctionCallOutputPayload::from_text("aborted".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
));
}
+1 -1
View File
@@ -235,7 +235,7 @@ fn build_text_message(role: &str, text_sections: Vec<String>) -> Option<Response
role: role.to_string(),
content,
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
})
}
+19 -19
View File
@@ -61,7 +61,7 @@ fn parses_user_message_with_text_and_two_images() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected user message turn item");
@@ -111,7 +111,7 @@ fn skips_local_image_label_text() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected user message turn item");
@@ -144,7 +144,7 @@ fn parses_assistant_message_input_text_for_backward_compatibility() {
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected assistant message turn item");
@@ -194,7 +194,7 @@ fn skips_unnamed_image_label_text() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected user message turn item");
@@ -227,7 +227,7 @@ fn skips_user_instructions_and_env() {
text: "# AGENTS.md instructions for test_directory\n\n<INSTRUCTIONS>\ntest_text\n</INSTRUCTIONS>".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -235,7 +235,7 @@ fn skips_user_instructions_and_env() {
text: "<environment_context>test_text</environment_context>".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -243,7 +243,7 @@ fn skips_user_instructions_and_env() {
text: "# AGENTS.md instructions for test_directory\n\n<INSTRUCTIONS>\ntest_text\n</INSTRUCTIONS>".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -252,7 +252,7 @@ fn skips_user_instructions_and_env() {
.to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -260,7 +260,7 @@ fn skips_user_instructions_and_env() {
text: "<user_shell_command>echo 42</user_shell_command>".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -275,7 +275,7 @@ fn skips_user_instructions_and_env() {
},
],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
];
for item in items {
@@ -325,7 +325,7 @@ fn parses_hook_prompt_and_hides_other_contextual_fragments() {
},
],
phase: None,
metadata: None,};
internal_chat_message_metadata_passthrough: None,};
let turn_item = parse_turn_item(&item).expect("expected hook prompt turn item");
@@ -357,7 +357,7 @@ fn internal_model_context_does_not_parse_as_visible_turn_item() {
.render(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert!(parse_turn_item(&item).is_none());
@@ -372,7 +372,7 @@ fn parses_agent_message() {
text: "Hello from Codex".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected agent message turn item");
@@ -404,7 +404,7 @@ fn parses_reasoning_summary_and_raw_content() {
text: "raw details".to_string(),
}]),
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected reasoning turn item");
@@ -437,7 +437,7 @@ fn parses_reasoning_including_raw_content() {
},
]),
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected reasoning turn item");
@@ -463,7 +463,7 @@ fn parses_web_search_call() {
query: Some("weather".to_string()),
queries: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected web search turn item");
@@ -492,7 +492,7 @@ fn parses_web_search_open_page_call() {
action: Some(WebSearchAction::OpenPage {
url: Some("https://example.com".to_string()),
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected web search turn item");
@@ -521,7 +521,7 @@ fn parses_web_search_find_in_page_call() {
url: Some("https://example.com".to_string()),
pattern: Some("needle".to_string()),
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected web search turn item");
@@ -548,7 +548,7 @@ fn parses_partial_web_search_call_without_action_as_other() {
id: Some("ws_partial".to_string()),
status: Some("in_progress".to_string()),
action: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_item = parse_turn_item(&item).expect("expected web search turn item");
+27 -27
View File
@@ -298,7 +298,7 @@ async fn seed_guardian_parent_history(session: &Arc<Session>, turn: &Arc<TurnCon
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -306,7 +306,7 @@ async fn seed_guardian_parent_history(session: &Arc<Session>, turn: &Arc<TurnCon
namespace: None,
arguments: "{\"repo\":\"openai/codex\"}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
@@ -314,7 +314,7 @@ async fn seed_guardian_parent_history(session: &Arc<Session>, turn: &Arc<TurnCon
output: codex_protocol::models::FunctionCallOutputPayload::from_text(
"repo visibility: public".to_string(),
),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -324,7 +324,7 @@ async fn seed_guardian_parent_history(session: &Arc<Session>, turn: &Arc<TurnCon
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
)
@@ -531,7 +531,7 @@ async fn build_guardian_prompt_delta_mode_preserves_original_numbering() -> anyh
text: "Please also push the second docs fix.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -540,7 +540,7 @@ async fn build_guardian_prompt_delta_mode_preserves_original_numbering() -> anyh
text: "I need approval for the second push.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
)
@@ -663,7 +663,7 @@ async fn build_guardian_prompt_stale_delta_version_falls_back_to_full_prompt() -
text: "Compacted retained user request.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -672,7 +672,7 @@ async fn build_guardian_prompt_stale_delta_version_falls_back_to_full_prompt() -
text: "Compacted summary of earlier guardian context.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
/*reference_context_item*/ None,
@@ -689,7 +689,7 @@ async fn build_guardian_prompt_stale_delta_version_falls_back_to_full_prompt() -
text: "Please push after the compaction.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -698,7 +698,7 @@ async fn build_guardian_prompt_stale_delta_version_falls_back_to_full_prompt() -
text: "I need approval for the post-compaction push.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
)
@@ -746,7 +746,7 @@ fn collect_guardian_transcript_entries_skips_contextual_user_messages() {
text: "<environment_context>\n<cwd>/tmp</cwd>\n</environment_context>".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -755,7 +755,7 @@ fn collect_guardian_transcript_entries_skips_contextual_user_messages() {
text: "hello".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -783,7 +783,7 @@ fn collect_guardian_transcript_entries_keeps_manual_approval_developer_message()
text: "ordinary developer context".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -792,7 +792,7 @@ fn collect_guardian_transcript_entries_keeps_manual_approval_developer_message()
text: approval_text.clone(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -817,7 +817,7 @@ fn collect_guardian_transcript_entries_includes_recent_tool_calls_and_output() {
text: "check the repo".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -825,7 +825,7 @@ fn collect_guardian_transcript_entries_includes_recent_tool_calls_and_output() {
namespace: None,
arguments: "{\"path\":\"README.md\"}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
@@ -833,7 +833,7 @@ fn collect_guardian_transcript_entries_includes_recent_tool_calls_and_output() {
output: codex_protocol::models::FunctionCallOutputPayload::from_text(
"repo is public".to_string(),
),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -842,7 +842,7 @@ fn collect_guardian_transcript_entries_includes_recent_tool_calls_and_output() {
text: "I need to push a fix".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -1698,7 +1698,7 @@ async fn guardian_review_request_layout_matches_model_visible_request_snapshot()
),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
)
.await;
@@ -1930,7 +1930,7 @@ async fn guardian_reuses_prompt_cache_key_and_appends_prior_reviews() -> anyhow:
text: "Please push the second docs fix too.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -1939,7 +1939,7 @@ async fn guardian_reuses_prompt_cache_key_and_appends_prior_reviews() -> anyhow:
text: "I need approval for the second docs fix.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
)
@@ -1977,7 +1977,7 @@ async fn guardian_reuses_prompt_cache_key_and_appends_prior_reviews() -> anyhow:
text: "Please push the third docs fix too.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -1986,7 +1986,7 @@ async fn guardian_reuses_prompt_cache_key_and_appends_prior_reviews() -> anyhow:
text: "I need approval for the third docs fix.".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
)
@@ -2726,7 +2726,7 @@ async fn guardian_ephemeral_retry_preserves_parallel_trunk_and_fork_history() ->
text: "Please inspect pending changes before pushing.".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
ResponseItem::Message {
id: None,
role: "assistant".to_string(),
@@ -2734,7 +2734,7 @@ async fn guardian_ephemeral_retry_preserves_parallel_trunk_and_fork_history() ->
text: "I need approval to run git diff.".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
],
)
.await;
@@ -2793,7 +2793,7 @@ async fn guardian_ephemeral_retry_preserves_parallel_trunk_and_fork_history() ->
text: "Now inspect whether pushing is safe.".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
ResponseItem::Message {
id: None,
role: "assistant".to_string(),
@@ -2801,7 +2801,7 @@ async fn guardian_ephemeral_retry_preserves_parallel_trunk_and_fork_history() ->
text: "I need approval to push after the diff check.".to_string(),
}],
phase: None,
metadata: None,},
internal_chat_message_metadata_passthrough: None,},
],
)
.await;
+4 -4
View File
@@ -49,7 +49,7 @@ fn preparation_preserves_small_image_bytes_and_non_data_urls() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
prepare_response_items(&mut items);
@@ -86,7 +86,7 @@ fn detail_policies_apply_the_expected_budgets() {
role: "user".to_string(),
content: vec![ContentItem::InputImage { image_url, detail }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
prepare_response_items(&mut items);
@@ -133,7 +133,7 @@ fn preparation_replaces_only_failed_tool_images_and_preserves_metadata() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
prepare_response_items(&mut items);
@@ -165,7 +165,7 @@ fn preparation_replaces_only_failed_tool_images_and_preserves_metadata() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]
);
}
+1 -1
View File
@@ -78,7 +78,7 @@ fn message(role: &str, content: ContentItem) -> ResponseItem {
role: role.to_string(),
content: vec![content],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -20,7 +20,7 @@ fn user_message(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -32,7 +32,7 @@ fn assistant_message(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -51,7 +51,7 @@ fn inter_agent_assistant_message(text: &str) -> ResponseItem {
text: serde_json::to_string(&communication).unwrap(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+26 -27
View File
@@ -107,8 +107,8 @@ use codex_protocol::config_types::ModeKind;
use codex_protocol::config_types::Settings;
use codex_protocol::models::BaseInstructions;
use codex_protocol::models::ContentItem;
use codex_protocol::models::InternalChatMessageMetadataPassthrough;
use codex_protocol::models::ResponseItem;
use codex_protocol::models::ResponseItemMetadata;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::CodexErrorInfo;
use codex_protocol::protocol::CompactedItem;
@@ -196,7 +196,7 @@ fn user_message(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -210,7 +210,7 @@ fn assign_missing_response_item_ids_skips_agent_messages() {
content: vec![AgentMessageInputContent::InputText {
text: "done".to_string(),
}],
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
user_message("hello"),
]);
@@ -229,7 +229,7 @@ fn assistant_message(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -289,7 +289,7 @@ fn skill_message(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -1636,9 +1636,8 @@ async fn reconstruct_history_uses_replacement_history_verbatim() {
text: "summary".to_string(),
}],
phase: None,
metadata: Some(ResponseItemMetadata {
internal_chat_message_metadata_passthrough: Some(InternalChatMessageMetadataPassthrough {
turn_id: Some("compact-turn".to_string()),
..Default::default()
}),
};
let replacement_history = vec![
@@ -1650,7 +1649,7 @@ async fn reconstruct_history_uses_replacement_history_verbatim() {
text: "stale developer instructions".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let first_window_id = Uuid::now_v7();
@@ -1722,7 +1721,7 @@ async fn prepares_image_failures_before_history_insertion() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
session
@@ -1757,7 +1756,7 @@ async fn prepares_image_failures_before_history_insertion() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
assert_eq!(history.raw_items(), expected.as_slice());
}
@@ -1778,7 +1777,7 @@ async fn prepares_resumed_history_before_installing_it() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
session
@@ -1803,7 +1802,7 @@ async fn prepares_resumed_history_before_installing_it() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]
);
}
@@ -7923,7 +7922,7 @@ async fn build_initial_context_omits_default_image_save_location_with_image_hist
status: "completed".to_string(),
revised_prompt: Some("a tiny blue square".to_string()),
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
/*reference_context_item*/ None,
)
@@ -8176,7 +8175,7 @@ async fn handle_output_item_done_records_image_save_history_message() {
status: "completed".to_string(),
revised_prompt: Some("a tiny blue square".to_string()),
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let mut ctx = HandleOutputCtx {
@@ -8233,7 +8232,7 @@ async fn handle_output_item_done_skips_image_save_message_when_save_fails() {
status: "completed".to_string(),
revised_prompt: Some("broken payload".to_string()),
result: "_-8".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let mut ctx = HandleOutputCtx {
@@ -8399,7 +8398,7 @@ async fn record_context_updates_and_set_reference_context_item_reinjects_full_co
text: format!("{}\nsummary", crate::compact::SUMMARY_PREFIX),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
session
.record_conversation_items(&turn_context, std::slice::from_ref(&compacted_summary))
@@ -8998,7 +8997,7 @@ async fn task_finish_emits_turn_item_lifecycle_for_leftover_pending_user_input()
text: "late pending input".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert!(
history.raw_items().iter().any(|item| item == &expected),
@@ -9431,7 +9430,7 @@ async fn abort_empty_active_turn_preserves_pending_input() {
text: "late pending input".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let turn_state = {
let mut active = sess.active_turn.lock().await;
@@ -9690,7 +9689,7 @@ async fn tool_calls_reopen_mailbox_delivery_for_current_turn() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let mut ctx = HandleOutputCtx {
sess: Arc::clone(&sess),
@@ -9818,7 +9817,7 @@ async fn fatal_tool_error_stops_turn_and_reports_error() {
call_id: "call-1".to_string(),
name: "shell_command".to_string(),
input: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let call = ToolRouter::build_tool_call(item.clone())
@@ -9903,7 +9902,7 @@ async fn sample_rollout(
text: "first user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
live_history.record_items(
std::iter::once(&user1),
@@ -9918,7 +9917,7 @@ async fn sample_rollout(
text: "assistant reply one".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
live_history.record_items(
std::iter::once(&assistant1),
@@ -9950,7 +9949,7 @@ async fn sample_rollout(
text: "second user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
live_history.record_items(
std::iter::once(&user2),
@@ -9965,7 +9964,7 @@ async fn sample_rollout(
text: "assistant reply two".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
live_history.record_items(
std::iter::once(&assistant2),
@@ -9997,7 +9996,7 @@ async fn sample_rollout(
text: "third user".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
live_history.record_items(
std::iter::once(&user3),
@@ -10012,7 +10011,7 @@ async fn sample_rollout(
text: "assistant reply three".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
live_history.record_items(
std::iter::once(&assistant3),
@@ -10158,7 +10157,7 @@ while :; do sleep 1; done"#,
})
.to_string(),
call_id: "shell-cleanup-call".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let call = ToolRouter::build_tool_call(item)?
.expect("shell command response item should build a tool call");
@@ -535,7 +535,7 @@ async fn process_compacted_history_preserves_separate_guardian_developer_message
text: "stale developer message".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -544,7 +544,7 @@ async fn process_compacted_history_preserves_separate_guardian_developer_message
text: "summary".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
],
InitialContextInjection::BeforeLastUserMessage,
+1 -1
View File
@@ -33,7 +33,7 @@ fn assistant_output_text(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+4 -4
View File
@@ -627,7 +627,7 @@ pub(crate) fn response_input_to_response_item(input: &ResponseInputItem) -> Opti
id: None,
call_id: call_id.clone(),
output: output.clone(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
})
}
ResponseInputItem::CustomToolCallOutput {
@@ -639,7 +639,7 @@ pub(crate) fn response_input_to_response_item(input: &ResponseInputItem) -> Opti
call_id: call_id.clone(),
name: name.clone(),
output: output.clone(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
ResponseInputItem::McpToolCallOutput { call_id, output } => {
let output = output.as_function_call_output_payload();
@@ -647,7 +647,7 @@ pub(crate) fn response_input_to_response_item(input: &ResponseInputItem) -> Opti
id: None,
call_id: call_id.clone(),
output,
metadata: None,
internal_chat_message_metadata_passthrough: None,
})
}
ResponseInputItem::ToolSearchOutput {
@@ -661,7 +661,7 @@ pub(crate) fn response_input_to_response_item(input: &ResponseInputItem) -> Opti
status: status.clone(),
execution: execution.clone(),
tools: tools.clone(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
_ => None,
}
+10 -10
View File
@@ -42,7 +42,7 @@ fn assistant_output_text_with_phase(text: &str, phase: Option<MessagePhase>) ->
text: text.to_string(),
}],
phase,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -53,7 +53,7 @@ fn external_context_pollution_items_include_web_search_and_tool_search() {
id: None,
status: Some("completed".to_string()),
action: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::ToolSearchCall {
id: None,
@@ -61,7 +61,7 @@ fn external_context_pollution_items_include_web_search_and_tool_search() {
status: None,
execution: "client".to_string(),
arguments: serde_json::json!({"query": "calendar"}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::ToolSearchOutput {
id: None,
@@ -69,7 +69,7 @@ fn external_context_pollution_items_include_web_search_and_tool_search() {
status: "completed".to_string(),
execution: "client".to_string(),
tools: Vec::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -94,7 +94,7 @@ fn external_context_pollution_items_exclude_local_tool_calls() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -102,13 +102,13 @@ fn external_context_pollution_items_exclude_local_tool_calls() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "call-1".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCall {
id: None,
@@ -116,14 +116,14 @@ fn external_context_pollution_items_exclude_local_tool_calls() {
call_id: "custom-1".to_string(),
name: "apply_patch".to_string(),
input: "*** Begin Patch\n*** End Patch\n".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
call_id: "custom-1".to_string(),
name: Some("apply_patch".to_string()),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
assistant_output_text("plain assistant text"),
];
@@ -425,7 +425,7 @@ fn completed_item_defers_mailbox_delivery_for_image_generation_calls() {
status: "completed".to_string(),
revised_prompt: None,
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert!(completed_item_defers_mailbox_delivery_to_next_turn(
+1 -1
View File
@@ -113,7 +113,7 @@ pub(crate) fn interrupted_turn_history_marker(
text: marker.render(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
})
}
}
+2 -2
View File
@@ -248,7 +248,7 @@ pub(crate) async fn exit_review_mode(
role: "user".to_string(),
content: vec![ContentItem::InputText { text: user_message }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
)
.await;
@@ -269,7 +269,7 @@ pub(crate) async fn exit_review_mode(
text: assistant_message,
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
)
.await;
+4 -4
View File
@@ -42,7 +42,7 @@ fn user_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
fn assistant_msg(text: &str) -> ResponseItem {
@@ -53,7 +53,7 @@ fn assistant_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -82,7 +82,7 @@ fn truncates_before_requested_user_message() {
}],
content: None,
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -90,7 +90,7 @@ fn truncates_before_requested_user_message() {
name: "tool".to_string(),
namespace: None,
arguments: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
assistant_msg("a4"),
];
@@ -15,7 +15,7 @@ fn user_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -27,7 +27,7 @@ fn assistant_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -39,7 +39,7 @@ fn developer_msg(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -79,7 +79,7 @@ fn truncates_rollout_from_start_before_nth_user_only() {
}],
content: None,
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -87,7 +87,7 @@ fn truncates_rollout_from_start_before_nth_user_only() {
name: "tool".to_string(),
namespace: None,
arguments: "{}".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
assistant_msg("a4"),
];
@@ -303,7 +303,7 @@ impl CoreTurnHost {
call_id,
name: Some(PUBLIC_TOOL_NAME.to_string()),
output: FunctionCallOutputPayload::from_text(text),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}])
.await
.map_err(|_| {
@@ -329,7 +329,7 @@ mod tests {
text: "extension history".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
session
.record_conversation_items(&turn, std::slice::from_ref(&history_item))
@@ -1198,11 +1198,6 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat
&& communication.other_recipients.is_empty()
&& communication.content.is_empty()
&& communication.encrypted_content.as_deref() == Some("encrypted-spawn-message")
&& communication
.metadata
.as_ref()
.and_then(|metadata| metadata.source_call_id.as_deref())
== Some("call-1")
&& communication.trigger_turn
)
}));
@@ -1230,11 +1225,6 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat
&& communication.other_recipients.is_empty()
&& communication.content.is_empty()
&& communication.encrypted_content.as_deref() == Some("encrypted-send-message")
&& communication
.metadata
.as_ref()
.and_then(|metadata| metadata.source_call_id.as_deref())
== Some("call-1")
&& !communication.trigger_turn
)
}));
@@ -2048,11 +2038,6 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn()
if communication.author == AgentPath::root()
&& communication.recipient == worker_path
&& communication.encrypted_content.as_deref() == Some("continue")
&& communication
.metadata
.as_ref()
.and_then(|metadata| metadata.source_call_id.as_deref())
== Some("call-1")
&& communication.trigger_turn
)
}));
@@ -2831,7 +2816,7 @@ async fn resume_agent_restores_closed_agent_and_accepts_send_input() {
text: "materialized".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
})]),
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("dummy")),
/*parent_trace*/ None,
@@ -6,7 +6,6 @@
use super::*;
use crate::tools::context::FunctionToolOutput;
use crate::turn_timing::now_unix_timestamp_ms;
use codex_protocol::models::ResponseItemMetadata;
use codex_protocol::protocol::InterAgentCommunication;
#[derive(Clone, Copy, PartialEq, Eq)]
@@ -100,12 +99,8 @@ pub(crate) async fn handle_message_string_tool(
.session_source
.get_agent_path()
.unwrap_or_else(AgentPath::root);
let mut communication =
let communication =
communication_from_tool_message(author, receiver_agent_path.clone(), message);
communication
.metadata
.get_or_insert_with(ResponseItemMetadata::default)
.source_call_id = Some(call_id.clone());
let result = session
.services
.agent_control
@@ -8,7 +8,6 @@ use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions;
use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v2;
use crate::turn_timing::now_unix_timestamp_ms;
use codex_protocol::AgentPath;
use codex_protocol::models::ResponseItemMetadata;
use codex_protocol::protocol::Op;
use codex_tools::ToolSpec;
@@ -123,12 +122,8 @@ async fn handle_spawn_agent(
.session_source
.get_agent_path()
.unwrap_or_else(AgentPath::root);
let mut communication =
let communication =
communication_from_tool_message(author, new_agent_path.clone(), message);
communication
.metadata
.get_or_insert_with(ResponseItemMetadata::default)
.source_call_id = Some(call_id.clone());
Op::InterAgentCommunication { communication }
}
initial_operation => initial_operation,
+3 -3
View File
@@ -157,7 +157,7 @@ async fn build_tool_call_uses_namespace_for_registry_name() -> anyhow::Result<()
namespace: Some("mcp__codex_apps__calendar".to_string()),
arguments: "{}".to_string(),
call_id: "call-namespace".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
})?
.expect("function_call should produce a tool call");
@@ -340,7 +340,7 @@ async fn extension_tool_executors_are_model_visible_and_dispatchable() -> anyhow
text: "extension history".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
session
.record_conversation_items(&turn, std::slice::from_ref(&history_item))
@@ -376,7 +376,7 @@ async fn extension_tool_executors_are_model_visible_and_dispatchable() -> anyhow
namespace: Some("extension/".to_string()),
arguments: json!({ "message": "hello" }).to_string(),
call_id: "call-extension".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
})?
.expect("function_call should produce a tool call");
let result = router
+5 -5
View File
@@ -112,7 +112,7 @@ fn response_item_records_turn_ttft_for_first_output_signals() {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
));
assert!(response_item_records_turn_ttft(
@@ -122,7 +122,7 @@ fn response_item_records_turn_ttft_for_first_output_signals() {
call_id: "call-2".to_string(),
name: "custom".to_string(),
input: "echo hi".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
));
assert!(response_item_records_turn_ttft(&ResponseItem::Message {
@@ -132,7 +132,7 @@ fn response_item_records_turn_ttft_for_first_output_signals() {
text: "hello".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}));
}
@@ -145,14 +145,14 @@ fn response_item_records_turn_ttft_ignores_empty_non_output_items() {
text: String::new(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}));
assert!(!response_item_records_turn_ttft(
&ResponseItem::FunctionCallOutput {
id: None,
call_id: "call-1".to_string(),
output: FunctionCallOutputPayload::from_text("ok".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
));
}
+1 -1
View File
@@ -684,7 +684,7 @@ pub fn user_message_item(text: &str) -> ResponseItem {
text: text.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+3 -3
View File
@@ -141,7 +141,7 @@ async fn responses_stream_includes_subagent_header_on_review() {
text: "hello".into(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut stream = client_session
@@ -273,7 +273,7 @@ async fn responses_stream_includes_subagent_header_on_other() {
text: "hello".into(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut stream = client_session
@@ -391,7 +391,7 @@ async fn responses_respects_model_info_overrides_from_config() {
text: "hello".into(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let mut stream = client_session
+23 -22
View File
@@ -186,7 +186,7 @@ fn assert_codex_client_metadata(
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn non_openai_responses_requests_omit_item_turn_metadata() {
async fn non_openai_responses_requests_omit_item_passthrough_metadata() {
let server = MockServer::start().await;
let response_mock = mount_sse_once(
&server,
@@ -230,8 +230,9 @@ async fn non_openai_responses_requests_omit_item_turn_metadata() {
assert!(!input.is_empty(), "request should include input items");
for item in input {
assert!(
item.get("metadata").is_none(),
"input item should omit metadata: {item}"
item.get("internal_chat_message_metadata_passthrough")
.is_none(),
"input item should omit internal chat message metadata passthrough: {item}"
);
assert!(
item.get("id").is_none(),
@@ -537,7 +538,7 @@ async fn resume_includes_initial_messages_and_sends_prior_items() {
text: "resumed user message".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let prior_user_json = serde_json::to_value(&prior_user).unwrap();
writeln!(
@@ -559,7 +560,7 @@ async fn resume_includes_initial_messages_and_sends_prior_items() {
text: "resumed system instruction".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let prior_system_json = serde_json::to_value(&prior_system).unwrap();
writeln!(
@@ -581,7 +582,7 @@ async fn resume_includes_initial_messages_and_sends_prior_items() {
text: "resumed assistant message".to_string(),
}],
phase: Some(MessagePhase::Commentary),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let prior_item_json = serde_json::to_value(&prior_item).unwrap();
writeln!(
@@ -724,7 +725,7 @@ async fn resume_replays_legacy_js_repl_image_rollout_shapes() {
call_id: "legacy-js-call".to_string(),
name: "js_repl".to_string(),
input: "console.log('legacy image flow')".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let legacy_image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
let thread_id = ThreadId::default();
@@ -757,7 +758,7 @@ async fn resume_replays_legacy_js_repl_image_rollout_shapes() {
call_id: "legacy-js-call".to_string(),
name: None,
output: FunctionCallOutputPayload::from_text("legacy js_repl stdout".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
},
RolloutLine {
@@ -770,7 +771,7 @@ async fn resume_replays_legacy_js_repl_image_rollout_shapes() {
detail: Some(DEFAULT_IMAGE_DETAIL),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
},
];
@@ -890,7 +891,7 @@ async fn resume_replays_image_tool_outputs_with_detail() {
namespace: None,
arguments: "{\"path\":\"/tmp/example.png\"}".to_string(),
call_id: function_call_id.to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
},
RolloutLine {
@@ -904,7 +905,7 @@ async fn resume_replays_image_tool_outputs_with_detail() {
detail: Some(ImageDetail::Original),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
},
RolloutLine {
@@ -915,7 +916,7 @@ async fn resume_replays_image_tool_outputs_with_detail() {
call_id: custom_call_id.to_string(),
name: "js_repl".to_string(),
input: "console.log('image flow')".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
},
RolloutLine {
@@ -930,7 +931,7 @@ async fn resume_replays_image_tool_outputs_with_detail() {
detail: Some(ImageDetail::Original),
},
]),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
},
];
@@ -1179,7 +1180,7 @@ async fn send_provider_auth_request(server: &MockServer, auth: ModelProviderAuth
text: "hello".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
let mut stream = client_session
@@ -2793,7 +2794,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
text: "content".into(),
}]),
encrypted_content: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
prompt.input.push(ResponseItem::Message {
id: Some("message-id".into()),
@@ -2802,7 +2803,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
text: "message".into(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
prompt.input.push(ResponseItem::WebSearchCall {
id: Some("web-search-id".into()),
@@ -2811,7 +2812,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
query: Some("weather".into()),
queries: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
prompt.input.push(ResponseItem::FunctionCall {
id: Some("function-id".into()),
@@ -2819,13 +2820,13 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
namespace: None,
arguments: "{}".into(),
call_id: "function-call-id".into(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
prompt.input.push(ResponseItem::FunctionCallOutput {
id: None,
call_id: "function-call-id".into(),
output: FunctionCallOutputPayload::from_text("ok".into()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
prompt.input.push(ResponseItem::LocalShellCall {
id: Some("local-shell-id".into()),
@@ -2838,7 +2839,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
env: None,
user: None,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
prompt.input.push(ResponseItem::CustomToolCall {
id: Some("custom-tool-id".into()),
@@ -2846,14 +2847,14 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
call_id: "custom-tool-call-id".into(),
name: "custom_tool".into(),
input: "{}".into(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
prompt.input.push(ResponseItem::CustomToolCallOutput {
id: None,
call_id: "custom-tool-call-id".into(),
name: None,
output: FunctionCallOutputPayload::from_text("ok".into()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
let mut stream = client_session
@@ -2059,7 +2059,7 @@ fn message_item(text: &str) -> ResponseItem {
role: "user".into(),
content: vec![ContentItem::InputText { text: text.into() }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -2069,7 +2069,7 @@ fn assistant_message_item(id: &str, text: &str) -> ResponseItem {
role: "assistant".into(),
content: vec![ContentItem::OutputText { text: text.into() }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+6 -6
View File
@@ -2037,12 +2037,12 @@ async fn auto_compact_runs_after_resume_when_token_usage_is_over_limit() {
text: remote_summary.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
codex_protocol::models::ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let compact_mock =
@@ -4163,12 +4163,12 @@ async fn auto_compact_counts_encrypted_reasoning_before_last_user() {
text: "REMOTE_COMPACT_SUMMARY".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
codex_protocol::models::ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let compact_mock =
@@ -4291,12 +4291,12 @@ async fn auto_compact_runs_when_reasoning_header_clears_between_turns() {
text: "REMOTE_COMPACT_SUMMARY".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
codex_protocol::models::ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let compact_mock =
+9 -9
View File
@@ -159,7 +159,7 @@ fn compacted_summary_only_output(summary: &str) -> Vec<ResponseItem> {
vec![ResponseItem::Compaction {
id: None,
encrypted_content: summary_with_prefix(summary),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]
}
@@ -333,7 +333,7 @@ async fn remote_compact_replaces_history_for_followups() -> Result<()> {
let compacted_history = vec![ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let compact_mock = responses::mount_compact_json_once(
harness.server(),
@@ -2361,7 +2361,7 @@ async fn remote_compact_persists_replacement_history_in_rollout() -> Result<()>
ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Message {
id: None,
@@ -2370,7 +2370,7 @@ async fn remote_compact_persists_replacement_history_in_rollout() -> Result<()>
text: "COMPACTED_ASSISTANT_NOTE".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let compact_mock = responses::mount_compact_json_once(
@@ -2512,12 +2512,12 @@ async fn remote_compact_and_resume_refresh_stale_developer_instructions() -> Res
text: stale_developer_message.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let compact_mock = responses::mount_compact_json_once(
@@ -2655,12 +2655,12 @@ async fn remote_compact_refreshes_stale_developer_instructions_without_resume()
text: stale_developer_message.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::Compaction {
id: None,
encrypted_content: "ENCRYPTED_COMPACTION_SUMMARY".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
let compact_mock = responses::mount_compact_json_once(
@@ -4067,7 +4067,7 @@ async fn snapshot_request_shape_remote_mid_turn_compaction_summary_only_reinject
let compacted_history = vec![ResponseItem::Compaction {
id: None,
encrypted_content: summary_with_prefix("REMOTE_SUMMARY_ONLY"),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
let compact_mock = responses::mount_compact_json_once(
harness.server(),
+2 -2
View File
@@ -178,7 +178,7 @@ async fn copy_paste_local_image_persists_rollout_request_shape() -> anyhow::Resu
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert_eq!(actual, expected);
@@ -269,7 +269,7 @@ async fn drag_drop_image_persists_rollout_request_shape() -> anyhow::Result<()>
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert_eq!(actual, expected);
@@ -49,7 +49,7 @@ async fn build_prompt_input_includes_context_and_user_message() -> Result<()> {
text: "hello from debug prompt".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert_eq!(input.last(), Some(&expected_user_message));
assert!(input.iter().any(|item| {
@@ -2350,7 +2350,7 @@ async fn conversation_startup_context_current_thread_selects_many_turns_by_budge
role: "user".to_string(),
content: vec![ContentItem::InputText { text: user_turn }],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
RolloutItem::ResponseItem(ResponseItem::Message {
id: None,
@@ -2359,7 +2359,7 @@ async fn conversation_startup_context_current_thread_selects_many_turns_by_budge
text: assistant_turn,
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
]
})
+2 -2
View File
@@ -532,7 +532,7 @@ async fn review_input_isolated_from_parent_history() {
text: "parent: earlier user message".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let user_json = serde_json::to_value(&user).unwrap();
let user_line = serde_json::json!({
@@ -552,7 +552,7 @@ async fn review_input_isolated_from_parent_history() {
text: "parent: assistant reply".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let assistant_json = serde_json::to_value(&assistant).unwrap();
let assistant_line = serde_json::json!({
@@ -1090,9 +1090,6 @@ async fn encrypted_multi_agent_v2_spawn_sends_agent_message_to_child() -> Result
"type": "agent_message",
"author": "/root",
"recipient": "/root/worker",
"metadata": {
"source_call_id": SPAWN_CALL_ID,
},
"content": [
{
"type": "input_text",
+8 -8
View File
@@ -76,7 +76,7 @@ async fn recent_image_fallback_selects_newest_images_in_chronological_order() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCall {
id: None,
@@ -84,13 +84,13 @@ async fn recent_image_fallback_selects_newest_images_in_chronological_order() {
namespace: None,
arguments: "{}".to_string(),
call_id: "mcp-call".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "mcp-call".to_string(),
output: image_output("mcp"),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCall {
id: None,
@@ -98,27 +98,27 @@ async fn recent_image_fallback_selects_newest_images_in_chronological_order() {
call_id: "code-mode-call".to_string(),
name: "exec".to_string(),
input: String::new(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::CustomToolCallOutput {
id: None,
call_id: "code-mode-call".to_string(),
name: Some("exec".to_string()),
output: image_output("code-mode"),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::ImageGenerationCall {
id: Some("generated-call".to_string()),
status: "completed".to_string(),
revised_prompt: None,
result: "generated".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: "orphan-call".to_string(),
output: image_output("orphan"),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
];
@@ -206,7 +206,7 @@ async fn recent_image_fallback_requires_requested_count() {
role: "user".to_string(),
content: vec![input_image("only-image")],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}],
&[],
)
+7 -7
View File
@@ -36,7 +36,7 @@ fn push_visible_message(messages: &mut Vec<ResponseItem>, item: &ResponseItem) {
ResponseItem::AgentMessage {
author,
content,
metadata,
internal_chat_message_metadata_passthrough: metadata,
..
} => {
if let Some(text) = plaintext_agent_message_content(content) {
@@ -47,7 +47,7 @@ fn push_visible_message(messages: &mut Vec<ResponseItem>, item: &ResponseItem) {
text: format!("Agent message from {author}:\n{text}"),
}],
phase: None,
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
});
}
}
@@ -56,7 +56,7 @@ fn push_visible_message(messages: &mut Vec<ResponseItem>, item: &ResponseItem) {
role,
content,
phase,
metadata,
internal_chat_message_metadata_passthrough: metadata,
} if role == USER_ROLE
&& matches!(parse_turn_item(item), Some(TurnItem::UserMessage(_))) =>
{
@@ -71,7 +71,7 @@ fn push_visible_message(messages: &mut Vec<ResponseItem>, item: &ResponseItem) {
role: role.clone(),
content,
phase: phase.clone(),
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
});
}
}
@@ -104,7 +104,7 @@ mod tests {
}
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
@@ -125,7 +125,7 @@ mod tests {
namespace: None,
arguments: "{}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
previous_assistant,
message("developer", "developer"),
@@ -158,7 +158,7 @@ mod tests {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let items = vec![
previous_user,
@@ -141,7 +141,7 @@ fn response_item(message: ConversationMessage) -> ResponseItem {
},
content: vec![content],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+8 -8
View File
@@ -303,7 +303,7 @@ mod job {
)?,
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
prompt.base_instructions = BaseInstructions {
text: crate::stage_one::PROMPT.to_string(),
@@ -429,7 +429,7 @@ mod job {
role,
content,
phase,
metadata,
internal_chat_message_metadata_passthrough: metadata,
} = item
else {
return should_persist_response_item_for_memories(item).then(|| item.clone());
@@ -457,7 +457,7 @@ mod job {
role: role.clone(),
content,
phase: phase.clone(),
metadata: metadata.clone(),
internal_chat_message_metadata_passthrough: metadata.clone(),
})
}
@@ -687,7 +687,7 @@ mod tests {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let skill_message = ResponseItem::Message {
id: None,
@@ -698,7 +698,7 @@ mod tests {
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let subagent_message = ResponseItem::Message {
id: None,
@@ -708,7 +708,7 @@ mod tests {
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let serialized = job::serialize_filtered_rollout_response_items(&[
@@ -730,7 +730,7 @@ mod tests {
.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
subagent_message,
]
@@ -750,7 +750,7 @@ mod tests {
),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
)])
.expect("serialize");
+1 -1
View File
@@ -685,7 +685,7 @@ async fn seed_stage1_candidate(
text: "remember this startup test conversation".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
};
let jsonl = serde_json::to_string(&line)?;
+1 -1
View File
@@ -404,7 +404,7 @@ pub fn build_hook_prompt_message(fragments: &[HookPromptFragment]) -> Option<Res
role: "user".to_string(),
content,
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
})
}
+201 -89
View File
@@ -904,14 +904,15 @@ pub enum MessagePhase {
FinalAnswer,
}
/// Internal Responses API passthrough metadata copied into underlying chat messages.
///
/// Responses API strongly types this payload. Do not modify it without first getting API
/// approval and making the corresponding Responses API change.
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, TS)]
pub struct ResponseItemMetadata {
pub struct InternalChatMessageMetadataPassthrough {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub turn_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub source_call_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema, TS)]
@@ -931,7 +932,7 @@ pub enum ResponseItem {
phase: Option<MessagePhase>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
AgentMessage {
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -942,7 +943,7 @@ pub enum ResponseItem {
content: Vec<AgentMessageInputContent>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
Reasoning {
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -955,7 +956,7 @@ pub enum ResponseItem {
encrypted_content: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
LocalShellCall {
/// Legacy id field retained for compatibility with older payloads.
@@ -968,7 +969,7 @@ pub enum ResponseItem {
action: LocalShellAction,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
FunctionCall {
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -985,7 +986,7 @@ pub enum ResponseItem {
call_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
ToolSearchCall {
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -1000,7 +1001,7 @@ pub enum ResponseItem {
arguments: serde_json::Value,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
// NOTE: The `output` field for `function_call_output` uses a dedicated payload type with
// custom serialization. On the wire it is either:
@@ -1017,7 +1018,7 @@ pub enum ResponseItem {
output: FunctionCallOutputPayload,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
CustomToolCall {
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -1032,7 +1033,7 @@ pub enum ResponseItem {
input: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
// `custom_tool_call_output.output` uses the same wire encoding as
// `function_call_output.output` so freeform tools can return either plain
@@ -1050,7 +1051,7 @@ pub enum ResponseItem {
output: FunctionCallOutputPayload,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
ToolSearchOutput {
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -1063,7 +1064,7 @@ pub enum ResponseItem {
tools: Vec<serde_json::Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
// Emitted by the Responses API when the agent triggers a web search.
// Example payload (from SSE `response.output_item.done`):
@@ -1085,7 +1086,7 @@ pub enum ResponseItem {
action: Option<WebSearchAction>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
// Emitted by the Responses API when the agent triggers image generation.
// Example payload:
@@ -1107,7 +1108,7 @@ pub enum ResponseItem {
result: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
#[serde(alias = "compaction_summary")]
Compaction {
@@ -1117,14 +1118,14 @@ pub enum ResponseItem {
encrypted_content: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
// Compaction triggers are request controls, and the Responses API does not
// accept an `id` field for them.
CompactionTrigger {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
ContextCompaction {
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -1135,7 +1136,7 @@ pub enum ResponseItem {
encrypted_content: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
metadata: Option<ResponseItemMetadata>,
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
},
#[serde(other)]
Other,
@@ -1191,7 +1192,7 @@ impl ResponseItem {
/// Returns the non-empty turn ID stamped onto this item, if present.
pub fn turn_id(&self) -> Option<&str> {
self.metadata()
self.internal_chat_message_metadata_passthrough()
.and_then(|metadata| metadata.turn_id.as_deref())
.filter(|turn_id| !turn_id.is_empty())
}
@@ -1201,59 +1202,154 @@ impl ResponseItem {
if turn_id.is_empty() || self.turn_id().is_some() {
return;
}
let Some(metadata) = self.metadata_mut() else {
let Some(metadata) = self.internal_chat_message_metadata_passthrough_mut() else {
return;
};
metadata
.get_or_insert_with(ResponseItemMetadata::default)
.get_or_insert_with(InternalChatMessageMetadataPassthrough::default)
.turn_id = Some(turn_id.to_string());
}
/// Removes Responses API item metadata before sending to a provider that does not accept it.
pub fn clear_metadata(&mut self) {
if let Some(metadata) = self.metadata_mut() {
/// Removes internal chat message metadata passthrough before sending to a provider that does
/// not accept it.
pub fn clear_internal_chat_message_metadata_passthrough(&mut self) {
if let Some(metadata) = self.internal_chat_message_metadata_passthrough_mut() {
*metadata = None;
}
}
fn metadata(&self) -> Option<&ResponseItemMetadata> {
fn internal_chat_message_metadata_passthrough(
&self,
) -> Option<&InternalChatMessageMetadataPassthrough> {
match self {
Self::Message { metadata, .. }
| Self::AgentMessage { metadata, .. }
| Self::Reasoning { metadata, .. }
| Self::LocalShellCall { metadata, .. }
| Self::FunctionCall { metadata, .. }
| Self::ToolSearchCall { metadata, .. }
| Self::FunctionCallOutput { metadata, .. }
| Self::CustomToolCall { metadata, .. }
| Self::CustomToolCallOutput { metadata, .. }
| Self::ToolSearchOutput { metadata, .. }
| Self::WebSearchCall { metadata, .. }
| Self::ImageGenerationCall { metadata, .. }
| Self::Compaction { metadata, .. }
| Self::CompactionTrigger { metadata, .. }
| Self::ContextCompaction { metadata, .. } => metadata.as_ref(),
Self::Message {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::AgentMessage {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::Reasoning {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::LocalShellCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::FunctionCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ToolSearchCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::FunctionCallOutput {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::CustomToolCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::CustomToolCallOutput {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ToolSearchOutput {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::WebSearchCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ImageGenerationCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::Compaction {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::CompactionTrigger {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ContextCompaction {
internal_chat_message_metadata_passthrough: metadata,
..
} => metadata.as_ref(),
Self::Other => None,
}
}
fn metadata_mut(&mut self) -> Option<&mut Option<ResponseItemMetadata>> {
fn internal_chat_message_metadata_passthrough_mut(
&mut self,
) -> Option<&mut Option<InternalChatMessageMetadataPassthrough>> {
match self {
Self::Message { metadata, .. }
| Self::AgentMessage { metadata, .. }
| Self::Reasoning { metadata, .. }
| Self::LocalShellCall { metadata, .. }
| Self::FunctionCall { metadata, .. }
| Self::ToolSearchCall { metadata, .. }
| Self::FunctionCallOutput { metadata, .. }
| Self::CustomToolCall { metadata, .. }
| Self::CustomToolCallOutput { metadata, .. }
| Self::ToolSearchOutput { metadata, .. }
| Self::WebSearchCall { metadata, .. }
| Self::ImageGenerationCall { metadata, .. }
| Self::Compaction { metadata, .. }
| Self::CompactionTrigger { metadata, .. }
| Self::ContextCompaction { metadata, .. } => Some(metadata),
Self::Message {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::AgentMessage {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::Reasoning {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::LocalShellCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::FunctionCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ToolSearchCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::FunctionCallOutput {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::CustomToolCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::CustomToolCallOutput {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ToolSearchOutput {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::WebSearchCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ImageGenerationCall {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::Compaction {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::CompactionTrigger {
internal_chat_message_metadata_passthrough: metadata,
..
}
| Self::ContextCompaction {
internal_chat_message_metadata_passthrough: metadata,
..
} => Some(metadata),
Self::Other => None,
}
}
@@ -1495,13 +1591,13 @@ impl From<ResponseInputItem> for ResponseItem {
content,
id: None,
phase,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseInputItem::FunctionCallOutput { call_id, output } => Self::FunctionCallOutput {
id: None,
call_id,
output,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseInputItem::McpToolCallOutput { call_id, output } => {
let output = output.into_function_call_output_payload();
@@ -1509,7 +1605,7 @@ impl From<ResponseInputItem> for ResponseItem {
id: None,
call_id,
output,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
ResponseInputItem::CustomToolCallOutput {
@@ -1521,7 +1617,7 @@ impl From<ResponseInputItem> for ResponseItem {
call_id,
name,
output,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
ResponseInputItem::ToolSearchOutput {
call_id,
@@ -1534,7 +1630,7 @@ impl From<ResponseInputItem> for ResponseItem {
execution,
tools,
id: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
},
}
}
@@ -2087,14 +2183,15 @@ mod tests {
text: "still working".to_string(),
}],
phase: Some(MessagePhase::Commentary),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
}
#[test]
fn response_item_metadata_round_trips_and_stamps_turn_ids() -> Result<()> {
let mut item = response_item_with_metadata(Some(response_item_metadata("turn-1")));
fn response_item_passthrough_metadata_round_trips_and_stamps_turn_ids() -> Result<()> {
let mut item =
response_item_with_passthrough_metadata(Some(passthrough_metadata("turn-1")));
let round_trip: ResponseItem = serde_json::from_value(serde_json::to_value(&item)?)?;
assert_eq!(round_trip, item);
@@ -2102,7 +2199,7 @@ mod tests {
"type": "message",
"role": "user",
"content": [{"type": "input_text", "text": "hello"}],
"metadata": {
"internal_chat_message_metadata_passthrough": {
"turn_id": "turn-1",
"other": "ignored",
},
@@ -2112,11 +2209,14 @@ mod tests {
item.stamp_turn_id_if_missing("turn-2");
assert_eq!(item.turn_id(), Some("turn-1"));
let mut empty_turn_id = response_item_with_metadata(Some(response_item_metadata("")));
let mut empty_turn_id =
response_item_with_passthrough_metadata(Some(passthrough_metadata("")));
empty_turn_id.stamp_turn_id_if_missing("turn-1");
assert_eq!(empty_turn_id.turn_id(), Some("turn-1"));
let mut missing_turn_id = response_item_with_metadata(/*metadata*/ None);
let mut missing_turn_id = response_item_with_passthrough_metadata(
/*internal_chat_message_metadata_passthrough*/ None,
);
missing_turn_id.stamp_turn_id_if_missing("");
missing_turn_id.stamp_turn_id_if_missing("turn-1");
assert_eq!(missing_turn_id.turn_id(), Some("turn-1"));
@@ -2129,7 +2229,9 @@ mod tests {
#[test]
fn response_item_id_getter_and_setter() {
let mut item = response_item_with_metadata(/*metadata*/ None);
let mut item = response_item_with_passthrough_metadata(
/*internal_chat_message_metadata_passthrough*/ None,
);
assert_eq!(item.id(), None);
item.set_id(Some("msg_test".to_string()));
@@ -2141,7 +2243,9 @@ mod tests {
assert_eq!(item.id(), None);
}
fn response_item_with_metadata(metadata: Option<ResponseItemMetadata>) -> ResponseItem {
fn response_item_with_passthrough_metadata(
internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
) -> ResponseItem {
ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -2149,14 +2253,13 @@ mod tests {
text: "hello".to_string(),
}],
phase: None,
metadata,
internal_chat_message_metadata_passthrough,
}
}
fn response_item_metadata(turn_id: &str) -> ResponseItemMetadata {
ResponseItemMetadata {
fn passthrough_metadata(turn_id: &str) -> InternalChatMessageMetadataPassthrough {
InternalChatMessageMetadataPassthrough {
turn_id: Some(turn_id.to_string()),
..Default::default()
}
}
@@ -2261,7 +2364,7 @@ mod tests {
status: "completed".to_string(),
revised_prompt: Some("A small blue square".to_string()),
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
}
@@ -2283,7 +2386,7 @@ mod tests {
status: "completed".to_string(),
revised_prompt: None,
result: "Zm9v".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
}
@@ -2635,7 +2738,7 @@ mod tests {
namespace: Some("mcp__codex_apps__gmail".to_string()),
arguments: "{\"top_k\":5}".to_string(),
call_id: "call-1".to_string(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
}
@@ -2983,7 +3086,7 @@ mod tests {
ResponseItem::Compaction {
id: None,
encrypted_content: "abc".into(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
Ok(())
@@ -3000,7 +3103,7 @@ mod tests {
ResponseItem::ContextCompaction {
id: None,
encrypted_content: Some("abc".into()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
Ok(())
@@ -3008,7 +3111,9 @@ mod tests {
#[test]
fn serializes_compaction_trigger_without_payload() -> Result<()> {
let item = ResponseItem::CompactionTrigger { metadata: None };
let item = ResponseItem::CompactionTrigger {
internal_chat_message_metadata_passthrough: None,
};
assert_eq!(
serde_json::to_value(item)?,
@@ -3020,15 +3125,17 @@ mod tests {
}
#[test]
fn serializes_stamped_compaction_trigger_metadata() -> Result<()> {
let mut item = ResponseItem::CompactionTrigger { metadata: None };
fn serializes_stamped_compaction_trigger_passthrough_metadata() -> Result<()> {
let mut item = ResponseItem::CompactionTrigger {
internal_chat_message_metadata_passthrough: None,
};
item.stamp_turn_id_if_missing("turn-1");
assert_eq!(
serde_json::to_value(item)?,
serde_json::json!({
"type": "compaction_trigger",
"metadata": {
"internal_chat_message_metadata_passthrough": {
"turn_id": "turn-1",
},
})
@@ -3042,7 +3149,12 @@ mod tests {
let item: ResponseItem = serde_json::from_str(json)?;
assert_eq!(item, ResponseItem::CompactionTrigger { metadata: None });
assert_eq!(
item,
ResponseItem::CompactionTrigger {
internal_chat_message_metadata_passthrough: None,
}
);
Ok(())
}
@@ -3134,7 +3246,7 @@ mod tests {
id: expected_id.clone(),
status: expected_status.clone(),
action: expected_action.clone(),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
assert_eq!(parsed, expected);
@@ -3219,7 +3331,7 @@ mod tests {
"query": "calendar create",
"limit": 1,
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
@@ -3281,7 +3393,7 @@ mod tests {
"additionalProperties": false,
}
})],
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
@@ -3335,7 +3447,7 @@ mod tests {
arguments: serde_json::json!({
"paths": ["crm"],
}),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
@@ -3356,7 +3468,7 @@ mod tests {
status: "completed".to_string(),
execution: "server".to_string(),
tools: vec![],
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
+3 -10
View File
@@ -42,7 +42,6 @@ use crate::models::MessagePhase;
use crate::models::PermissionProfile;
use crate::models::ResponseInputItem;
use crate::models::ResponseItem;
use crate::models::ResponseItemMetadata;
use crate::models::SandboxEnforcement;
use crate::models::WebSearchAction;
use crate::num_format::format_with_separators;
@@ -697,9 +696,6 @@ pub struct InterAgentCommunication {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub encrypted_content: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<ResponseItemMetadata>,
pub trigger_turn: bool,
}
@@ -717,7 +713,6 @@ impl InterAgentCommunication {
other_recipients,
content,
encrypted_content: None,
metadata: None,
trigger_turn,
}
}
@@ -735,7 +730,6 @@ impl InterAgentCommunication {
other_recipients,
content: String::new(),
encrypted_content: Some(encrypted_content),
metadata: None,
trigger_turn,
}
}
@@ -779,7 +773,7 @@ impl InterAgentCommunication {
author: self.author.to_string(),
recipient: self.recipient.to_string(),
content,
metadata: self.metadata.clone(),
internal_chat_message_metadata_passthrough: None,
}
}
@@ -3060,7 +3054,7 @@ impl From<CompactedItem> for ResponseItem {
text: value.message,
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
}
@@ -4349,7 +4343,6 @@ mod tests {
other_recipients: vec![AgentPath::root().join("worker").expect("recipient path")],
content: "review the diff".to_string(),
encrypted_content: None,
metadata: None,
trigger_turn: true,
};
@@ -4390,7 +4383,7 @@ mod tests {
encrypted_content: "encrypted payload".to_string(),
},
],
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
);
}
+1 -1
View File
@@ -504,7 +504,7 @@ mod tests {
text: "raw reasoning".to_string(),
}]),
encrypted_content: Some("encoded".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
let normal = serde_json::to_value(&item).expect("response item serializes");
+1 -1
View File
@@ -1320,7 +1320,7 @@ async fn test_updated_at_uses_file_mtime() -> Result<()> {
text: format!("reply-{idx}"),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
};
writeln!(file, "{}", serde_json::to_string(&response_line)?)?;
+1 -1
View File
@@ -191,7 +191,7 @@ mod tests {
text: "hello from response item".to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
});
apply_rollout_item(&mut metadata, &item, "test-provider");
+1 -1
View File
@@ -513,7 +513,7 @@ mod tests {
id: None,
call_id: "call-1".to_string(),
output: FunctionCallOutputPayload::from_text("tool output".to_string()),
metadata: None,
internal_chat_message_metadata_passthrough: None,
}),
RolloutItem::EventMsg(EventMsg::TokenCount(
codex_protocol::protocol::TokenCountEvent {
+1 -1
View File
@@ -95,7 +95,7 @@ mod tests {
}
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}
+1 -1
View File
@@ -462,7 +462,7 @@ impl App {
text: SIDE_BOUNDARY_PROMPT.to_string(),
}],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}
}