Merge b8b9816102 into sapling-pr-archive-bolinfest

This commit is contained in:
Michael Bolin
2026-06-22 12:15:30 -07:00
committed by GitHub
164 changed files with 3240 additions and 1600 deletions
+4 -1
View File
@@ -173,8 +173,11 @@ jobs:
runner: macos-15-xlarge
timeout_minutes: 30
- name: Windows
runner: windows-2022
runner: windows-x64
timeout_minutes: 30
runs_on:
group: ${{ github.event.repository.name }}-runners
labels: ${{ github.event.repository.name }}-windows-x64
steps:
- name: Check whether argument comment lint should run
id: argument_comment_lint_gate
+5 -6
View File
@@ -2,18 +2,17 @@ module(name = "codex")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "llvm", version = "0.7.1")
bazel_dep(name = "llvm", version = "0.7.9")
# The upstream LLVM archive contains a few unix-only symlink entries and is
# missing a couple of MinGW compatibility archives that windows-gnullvm needs
# during extraction and linking, so patch it until upstream grows native support.
# Patch hermetic LLVM for Codex's custom libc++ and Windows gnullvm runtime
# needs that have not landed upstream.
single_version_override(
module_name = "llvm",
patch_strip = 1,
patches = [
"//patches:llvm_rusty_v8_custom_libcxx.patch",
"//patches:llvm_windows_arm64_powl.patch",
"//patches:llvm_windows_symlink_extract.patch",
"//patches:llvm_windows_mingw_compat.patch",
],
)
@@ -80,7 +79,7 @@ use_repo(osx, "macos_sdk")
# Needed to disable xcode...
bazel_dep(name = "apple_support", version = "2.1.0")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_cc", version = "0.2.18")
single_version_override(
module_name = "rules_cc",
patch_strip = 1,
+8 -4
View File
@@ -45,6 +45,7 @@
"https://bcr.bazel.build/modules/bazel_features/1.34.0/MODULE.bazel": "e8475ad7c8965542e0c7aac8af68eb48c4af904be3d614b6aa6274c092c2ea1e",
"https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7",
"https://bcr.bazel.build/modules/bazel_features/1.42.0/MODULE.bazel": "e8ca15cb2639c5f12183db6dcb678735555d0cdd739b32a0418b6532b5e565f8",
"https://bcr.bazel.build/modules/bazel_features/1.43.0/MODULE.bazel": "defa2226f06ba20550d6548c3a2ea2a7929634437a52973869c20c225450eb91",
"https://bcr.bazel.build/modules/bazel_features/1.45.0/MODULE.bazel": "7daec6d87ab0703417486d4cb948af0b06f55d4d7c08cbb5978c80e79b538edf",
"https://bcr.bazel.build/modules/bazel_features/1.45.0/source.json": "635e4536e09ff125b8972e0fa239c135fde5f18701f7d5115680560651dfb41d",
"https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b",
@@ -63,6 +64,7 @@
"https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917",
"https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d",
"https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b",
"https://bcr.bazel.build/modules/bazel_skylib/1.8.0/MODULE.bazel": "2fb3fb53675f6adfc1ca5bfbd5cfb655ae350fba4706d924a8ec7e3ba945671c",
"https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6",
"https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67",
"https://bcr.bazel.build/modules/bazel_skylib/1.9.0/MODULE.bazel": "72997b29dfd95c3fa0d0c48322d05590418edef451f8db8db5509c57875fb4b7",
@@ -87,8 +89,8 @@
"https://bcr.bazel.build/modules/libcap/2.27.bcr.1/source.json": "3b116cbdbd25a68ffb587b672205f6d353a4c19a35452e480d58fc89531e0a10",
"https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902",
"https://bcr.bazel.build/modules/llvm/0.7.0/MODULE.bazel": "3c07a4e5734b0ad41fe24dedaacbf3a35ce4377b7e1a21f24488a0c9ac4f1e6b",
"https://bcr.bazel.build/modules/llvm/0.7.1/MODULE.bazel": "74ac75efc6385b8a95d83bfa36ad399500f747c3d0f50287f9b6f9e854ec4814",
"https://bcr.bazel.build/modules/llvm/0.7.1/source.json": "0cac59d04dafa0ca1f70ea21cf1569e034ef8736c2c7510e834a9e8141d7e631",
"https://bcr.bazel.build/modules/llvm/0.7.9/MODULE.bazel": "452b272a6b5ecc8747db8e5b7fd9d6799ef0db17b8d437aa8d4dda4f56a3e9ea",
"https://bcr.bazel.build/modules/llvm/0.7.9/source.json": "0c098ab546a8c4b0a720dcb010714e13f9ba6ceab0d23a87b7f1083788928c31",
"https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74",
"https://bcr.bazel.build/modules/openssl/3.5.4.bcr.0/MODULE.bazel": "0f6b8f20b192b9ff0781406256150bcd46f19e66d807dcb0c540548439d6fc35",
"https://bcr.bazel.build/modules/openssl/3.5.4.bcr.0/source.json": "543ed7627cc18e6460b9c1ae4a1b6b1debc5a5e0aca878b00f7531c7186b73da",
@@ -143,7 +145,8 @@
"https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37",
"https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8",
"https://bcr.bazel.build/modules/rules_cc/0.2.16/MODULE.bazel": "9242fa89f950c6ef7702801ab53922e99c69b02310c39fb6e62b2bd30df2a1d4",
"https://bcr.bazel.build/modules/rules_cc/0.2.16/source.json": "d03d5cde49376d87e14ec14b666c56075e5e3926930327fd5d0484a1ff2ac1cc",
"https://bcr.bazel.build/modules/rules_cc/0.2.18/MODULE.bazel": "4460ec36adc8f722a6a2a4ac9374cb91f2acebadaa93fc37966129afb3dece87",
"https://bcr.bazel.build/modules/rules_cc/0.2.18/source.json": "abad668ff2fd63ada1ac49bf386d37e27048b89a3465a6fd968bb832b00a09d3",
"https://bcr.bazel.build/modules/rules_cc/0.2.4/MODULE.bazel": "1ff1223dfd24f3ecf8f028446d4a27608aa43c3f41e346d22838a4223980b8cc",
"https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642",
"https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6",
@@ -221,8 +224,9 @@
"https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "75aab2373a4bbe2a1260b9bf2a1ebbdbf872d3bd36f80bff058dccd82e89422f",
"https://bcr.bazel.build/modules/tar.bzl/0.10.4/MODULE.bazel": "e8f9ff79199e8d9eaad7f1b0a77ad74b30bb82d794b87d8ca942bead5de83ae9",
"https://bcr.bazel.build/modules/tar.bzl/0.10.4/source.json": "20143442376c03426f6135292ba02d825cb75308aa47e6bf42dd4cc5a435c2ff",
"https://bcr.bazel.build/modules/tar.bzl/0.9.0/MODULE.bazel": "452a22d7f02b1c9d7a22ab25edf20f46f3e1101f0f67dc4bfbf9a474ddf02445",
"https://bcr.bazel.build/modules/tar.bzl/0.9.0/source.json": "c732760a374831a2cf5b08839e4be75017196b4d796a5aa55235272ee17cd839",
"https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43",
"https://bcr.bazel.build/modules/with_cfg.bzl/0.12.0/MODULE.bazel": "b573395fe63aef4299ba095173e2f62ccfee5ad9bbf7acaa95dba73af9fc2b38",
"https://bcr.bazel.build/modules/with_cfg.bzl/0.12.0/source.json": "3f3fbaeafecaf629877ad152a2c9def21f8d330d91aa94c5dc75bbb98c10b8b8",
@@ -3504,10 +3504,11 @@ async fn reducer_ingests_plugin_install_failed_fact() {
async fn reducer_ingests_plugin_install_failed_fact_without_detail() {
let mut reducer = AnalyticsReducer::default();
let mut events = Vec::new();
let mut plugin = PluginTelemetryMetadata::from_plugin_id(
&PluginId::parse("unknown@openai-curated-remote").expect("valid plugin id"),
);
plugin.remote_plugin_id = Some("plugins~Plugin_00000000000000000000000000000000".to_string());
let plugin = PluginTelemetryMetadata {
plugin_id: PluginId::parse("unknown@openai-curated-remote").expect("valid plugin id"),
remote_plugin_id: Some("plugins~Plugin_00000000000000000000000000000000".to_string()),
capability_summary: None,
};
reducer
.ingest(
+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(),
@@ -337,7 +337,6 @@ use codex_core_plugins::PluginUninstallError as CorePluginUninstallError;
use codex_core_plugins::PluginsManager;
use codex_core_plugins::loader::load_plugin_apps;
use codex_core_plugins::loader::load_plugin_mcp_servers;
use codex_core_plugins::loader::plugin_telemetry_metadata_from_root;
use codex_core_plugins::manifest::PluginManifestInterface;
use codex_core_plugins::marketplace::MarketplaceError;
use codex_core_plugins::marketplace::MarketplacePluginSource;
@@ -295,15 +295,14 @@ impl ConfigRequestProcessor {
&self,
pending_changes: std::collections::BTreeMap<String, bool>,
) {
let plugins_manager = self.thread_manager.plugins_manager();
for (plugin_id, enabled) in pending_changes {
let Ok(plugin_id) = PluginId::parse(&plugin_id) else {
continue;
};
let metadata = codex_core_plugins::loader::installed_plugin_telemetry_metadata(
self.config_manager.codex_home(),
&plugin_id,
)
.await;
let metadata = plugins_manager
.telemetry_metadata_for_installed_plugin(&plugin_id)
.await;
if enabled {
self.analytics_events_client.track_plugin_enabled(metadata);
} else {
@@ -23,7 +23,6 @@ use codex_mcp::McpOAuthLoginSupport;
use codex_mcp::oauth_login_support;
use codex_mcp::should_retry_without_scopes;
use codex_plugin::PluginId;
use codex_plugin::PluginTelemetryMetadata;
use codex_rmcp_client::perform_oauth_login_silent;
#[derive(Clone)]
@@ -1620,9 +1619,14 @@ impl PluginRequestProcessor {
Some(self.effective_plugins_changed_callback()),
);
let mut plugin_metadata =
plugin_telemetry_metadata_from_root(&result.plugin_id, &result.installed_path).await;
plugin_metadata.remote_plugin_id = Some(remote_plugin_id.clone());
let plugin_metadata = self
.thread_manager
.plugins_manager()
.telemetry_metadata_for_installed_plugin_with_remote_id(
&result.plugin_id,
&remote_plugin_id,
)
.await;
self.analytics_events_client
.track_plugin_installed(plugin_metadata);
@@ -1713,8 +1717,10 @@ impl PluginRequestProcessor {
else {
return;
};
let mut plugin = PluginTelemetryMetadata::from_plugin_id(&plugin_id);
plugin.remote_plugin_id = Some(remote_plugin_id.to_string());
let plugin = self
.thread_manager
.plugins_manager()
.telemetry_metadata_for_plugin_id_with_remote_id(&plugin_id, remote_plugin_id);
self.analytics_events_client
.track_plugin_install_failed(plugin, error_type.to_string());
}
@@ -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(
@@ -38,6 +38,8 @@ use tempfile::TempDir;
use tokio::time::timeout;
use wiremock::MockServer;
const TINY_PNG_DATA_URL: &str = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
// macOS and Windows Bazel CI can spend tens of seconds starting app-server
// subprocesses or processing test RPCs under load.
#[cfg(any(target_os = "macos", windows))]
@@ -650,7 +652,7 @@ async fn dynamic_tool_call_round_trip_sends_content_items_to_model() -> Result<(
text: "dynamic-ok".to_string(),
},
DynamicToolCallOutputContentItem::InputImage {
image_url: "data:image/png;base64,AAA".to_string(),
image_url: TINY_PNG_DATA_URL.to_string(),
},
];
let content_items = response_content_items
@@ -695,7 +697,7 @@ async fn dynamic_tool_call_round_trip_sends_content_items_to_model() -> Result<(
text: "dynamic-ok".to_string(),
},
DynamicToolCallOutputContentItem::InputImage {
image_url: "data:image/png;base64,AAA".to_string(),
image_url: TINY_PNG_DATA_URL.to_string(),
},
])
);
@@ -721,7 +723,7 @@ async fn dynamic_tool_call_round_trip_sends_content_items_to_model() -> Result<(
},
{
"type": "input_image",
"image_url": "data:image/png;base64,AAA",
"image_url": TINY_PNG_DATA_URL,
"detail": "high"
}
])
@@ -28,13 +28,13 @@ use wiremock::ResponseTemplate;
use wiremock::matchers::method;
use wiremock::matchers::path;
const RESULT: &str = "cG5n";
const RESULT: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
const TINY_PNG_BYTES: &[u8] = &[
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0,
0, 0, 31, 21, 196, 137, 0, 0, 0, 11, 73, 68, 65, 84, 120, 156, 99, 96, 0, 2, 0, 0, 5, 0, 1,
122, 94, 171, 63, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130,
0, 0, 31, 21, 196, 137, 0, 0, 0, 13, 73, 68, 65, 84, 120, 156, 99, 248, 207, 192, 240, 31, 0,
5, 0, 1, 255, 137, 153, 61, 29, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130,
];
const TINY_PNG_DATA_URL: &str = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4nGNgAAIAAAUAAXpeqz8AAAAASUVORK5CYII=";
const TINY_PNG_DATA_URL: &str = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
#[derive(Clone, Copy)]
enum ImagegenTestMode {
@@ -116,7 +116,7 @@ async fn standalone_image_generation_returns_saved_path_hint_to_model() -> Resul
assert_eq!(status, "completed");
assert_eq!(revised_prompt.as_deref(), Some("paint a blue whale"));
assert_eq!(result, RESULT);
assert_eq!(std::fs::read(&saved_path)?, b"png");
assert_eq!(std::fs::read(&saved_path)?, TINY_PNG_BYTES);
let requests = response_mock.requests();
assert_eq!(requests.len(), 2);
@@ -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 -36
View File
@@ -38,7 +38,6 @@ use codex_plugin::PluginCapabilitySummary;
use codex_plugin::PluginHookSource;
use codex_plugin::PluginId;
use codex_plugin::PluginIdError;
use codex_plugin::PluginTelemetryMetadata;
use codex_plugin::app_connector_ids_from_declarations;
use codex_protocol::protocol::Product;
use codex_protocol::protocol::SkillScope;
@@ -1164,13 +1163,11 @@ fn cleaned_app_category(category: Option<String>) -> Option<String> {
.filter(|category| !category.is_empty())
}
pub async fn plugin_telemetry_metadata_from_root(
pub async fn plugin_capability_summary_from_root(
plugin_id: &PluginId,
plugin_root: &AbsolutePathBuf,
) -> PluginTelemetryMetadata {
let Some(manifest) = load_plugin_manifest(plugin_root.as_path()) else {
return PluginTelemetryMetadata::from_plugin_id(plugin_id);
};
) -> Option<PluginCapabilitySummary> {
let manifest = load_plugin_manifest(plugin_root.as_path())?;
let manifest_paths = &manifest.paths;
let has_skills = !plugin_skill_roots(plugin_root, manifest_paths).is_empty();
@@ -1192,18 +1189,14 @@ pub async fn plugin_telemetry_metadata_from_root(
.await;
let app_connector_ids = app_connector_ids_from_declarations(&app_declarations);
PluginTelemetryMetadata {
plugin_id: plugin_id.clone(),
remote_plugin_id: None,
capability_summary: Some(PluginCapabilitySummary {
config_name: plugin_id.as_key(),
display_name: plugin_id.plugin_name.clone(),
description: None,
has_skills,
mcp_server_names,
app_connector_ids,
}),
}
Some(PluginCapabilitySummary {
config_name: plugin_id.as_key(),
display_name: plugin_id.plugin_name.clone(),
description: None,
has_skills,
mcp_server_names,
app_connector_ids,
})
}
pub async fn load_plugin_mcp_servers(
@@ -1279,24 +1272,6 @@ pub(crate) async fn load_plugin_mcp_servers_from_manifest(
mcp_servers
}
pub async fn installed_plugin_telemetry_metadata(
codex_home: &Path,
plugin_id: &PluginId,
) -> PluginTelemetryMetadata {
let store = match PluginStore::try_new(codex_home.to_path_buf()) {
Ok(store) => store,
Err(err) => {
warn!("failed to resolve plugin cache root: {err}");
return PluginTelemetryMetadata::from_plugin_id(plugin_id);
}
};
let Some(plugin_root) = store.active_plugin_root(plugin_id) else {
return PluginTelemetryMetadata::from_plugin_id(plugin_id);
};
plugin_telemetry_metadata_from_root(plugin_id, &plugin_root).await
}
async fn load_mcp_servers_from_file(
plugin_root: &Path,
mcp_config_path: &AbsolutePathBuf,
+67 -5
View File
@@ -6,7 +6,6 @@ use crate::is_openai_curated_marketplace_name;
use crate::loader::PluginHookLoadOutcome;
use crate::loader::configured_curated_plugin_ids_from_codex_home;
use crate::loader::curated_plugin_cache_version;
use crate::loader::installed_plugin_telemetry_metadata;
use crate::loader::load_plugin_apps_from_manifest;
use crate::loader::load_plugin_hooks;
use crate::loader::load_plugin_hooks_from_layer_stack;
@@ -15,7 +14,7 @@ use crate::loader::load_plugin_skills;
use crate::loader::load_plugins_from_layer_stack;
use crate::loader::log_plugin_load_errors;
use crate::loader::materialize_marketplace_plugin_source;
use crate::loader::plugin_telemetry_metadata_from_root;
use crate::loader::plugin_capability_summary_from_root;
use crate::loader::refresh_curated_plugin_cache;
use crate::loader::refresh_non_curated_plugin_cache;
use crate::loader::refresh_non_curated_plugin_cache_force_reinstall;
@@ -709,6 +708,66 @@ impl PluginsManager {
remote_installed_plugins_to_config(plugins, &self.store)
}
pub async fn telemetry_metadata_for_installed_plugin(
&self,
plugin_id: &PluginId,
) -> PluginTelemetryMetadata {
let mut metadata = self.telemetry_metadata_for_plugin_id(plugin_id);
metadata.capability_summary = match self.store.active_plugin_root(plugin_id) {
Some(plugin_root) => plugin_capability_summary_from_root(plugin_id, &plugin_root).await,
None => None,
};
metadata
}
pub async fn telemetry_metadata_for_installed_plugin_with_remote_id(
&self,
plugin_id: &PluginId,
remote_plugin_id: &str,
) -> PluginTelemetryMetadata {
let mut metadata =
self.telemetry_metadata_for_plugin_id_with_remote_id(plugin_id, remote_plugin_id);
metadata.capability_summary = match self.store.active_plugin_root(plugin_id) {
Some(plugin_root) => plugin_capability_summary_from_root(plugin_id, &plugin_root).await,
None => None,
};
metadata
}
pub fn telemetry_metadata_for_plugin_id(
&self,
plugin_id: &PluginId,
) -> PluginTelemetryMetadata {
PluginTelemetryMetadata {
plugin_id: plugin_id.clone(),
remote_plugin_id: None,
capability_summary: None,
}
}
pub fn telemetry_metadata_for_plugin_id_with_remote_id(
&self,
plugin_id: &PluginId,
remote_plugin_id: &str,
) -> PluginTelemetryMetadata {
PluginTelemetryMetadata {
remote_plugin_id: Some(remote_plugin_id.to_string()),
..self.telemetry_metadata_for_plugin_id(plugin_id)
}
}
pub fn telemetry_metadata_for_capability_summary(
&self,
summary: &PluginCapabilitySummary,
) -> Option<PluginTelemetryMetadata> {
let plugin_id = PluginId::parse(&summary.config_name).ok()?;
Some(PluginTelemetryMetadata {
plugin_id,
remote_plugin_id: None,
capability_summary: Some(summary.clone()),
})
}
pub fn build_remote_installed_plugin_marketplaces_from_cache(
&self,
visible_marketplaces: &[&str],
@@ -1281,7 +1340,7 @@ impl PluginsManager {
};
if let Some(analytics_events_client) = analytics_events_client {
analytics_events_client.track_plugin_install_failed(
PluginTelemetryMetadata::from_plugin_id(plugin_id),
self.telemetry_metadata_for_plugin_id(plugin_id),
error_type.to_string(),
);
}
@@ -1351,7 +1410,7 @@ impl PluginsManager {
};
if let Some(analytics_events_client) = analytics_events_client {
analytics_events_client.track_plugin_installed(
plugin_telemetry_metadata_from_root(&result.plugin_id, &result.installed_path)
self.telemetry_metadata_for_installed_plugin(&result.plugin_id)
.await,
);
}
@@ -1392,7 +1451,10 @@ impl PluginsManager {
async fn uninstall_plugin_id(&self, plugin_id: PluginId) -> Result<(), PluginUninstallError> {
let plugin_telemetry = if self.store.active_plugin_root(&plugin_id).is_some() {
Some(installed_plugin_telemetry_metadata(self.codex_home.as_path(), &plugin_id).await)
Some(
self.telemetry_metadata_for_installed_plugin(&plugin_id)
.await,
)
} else {
None
};
+80 -5
View File
@@ -845,6 +845,81 @@ remote_plugin = true
assert_eq!(outcome, PluginLoadOutcome::default());
}
#[tokio::test]
async fn installed_plugin_telemetry_metadata_collects_capabilities() {
let codex_home = TempDir::new().unwrap();
write_cached_plugin(codex_home.path(), "test", "sample");
let manager = PluginsManager::new(codex_home.path().to_path_buf());
let plugin_id = PluginId::parse("sample@test").expect("plugin id should parse");
let metadata = manager
.telemetry_metadata_for_installed_plugin(&plugin_id)
.await;
assert_eq!(
metadata,
PluginTelemetryMetadata {
plugin_id,
remote_plugin_id: None,
capability_summary: Some(PluginCapabilitySummary {
config_name: "sample@test".to_string(),
display_name: "sample".to_string(),
description: None,
has_skills: true,
mcp_server_names: Vec::new(),
app_connector_ids: Vec::new(),
}),
}
);
}
#[tokio::test]
async fn installed_plugin_telemetry_metadata_accepts_authoritative_remote_identity() {
let codex_home = TempDir::new().unwrap();
let manager = PluginsManager::new(codex_home.path().to_path_buf());
let plugin_id =
PluginId::parse("linear@openai-curated-remote").expect("plugin id should parse");
let metadata = manager
.telemetry_metadata_for_installed_plugin_with_remote_id(&plugin_id, "plugins~Plugin_linear")
.await;
assert_eq!(
metadata,
PluginTelemetryMetadata {
plugin_id,
remote_plugin_id: Some("plugins~Plugin_linear".to_string()),
capability_summary: None,
}
);
}
#[test]
fn capability_summary_telemetry_metadata_uses_local_identity() {
let codex_home = TempDir::new().unwrap();
let manager = PluginsManager::new(codex_home.path().to_path_buf());
let summary = PluginCapabilitySummary {
config_name: "linear@openai-curated-remote".to_string(),
display_name: "Linear".to_string(),
description: Some("Track work".to_string()),
has_skills: true,
mcp_server_names: vec!["linear".to_string()],
app_connector_ids: vec![AppConnectorId("linear-app".to_string())],
};
let metadata = manager.telemetry_metadata_for_capability_summary(&summary);
assert_eq!(
metadata,
Some(PluginTelemetryMetadata {
plugin_id: PluginId::parse("linear@openai-curated-remote")
.expect("plugin id should parse"),
remote_plugin_id: None,
capability_summary: Some(summary),
})
);
}
#[tokio::test]
async fn remote_installed_cache_prefers_local_curated_conflicts_when_remote_plugin_disabled() {
let codex_home = TempDir::new().unwrap();
@@ -1154,14 +1229,14 @@ async fn plugin_telemetry_metadata_uses_default_mcp_config_path() {
}"#,
);
let metadata = plugin_telemetry_metadata_from_root(
let summary = plugin_capability_summary_from_root(
&PluginId::parse("sample@test").expect("plugin id should parse"),
&plugin_root.abs(),
)
.await;
assert_eq!(
metadata.capability_summary,
summary,
Some(PluginCapabilitySummary {
config_name: "sample@test".to_string(),
display_name: "sample".to_string(),
@@ -1174,7 +1249,7 @@ async fn plugin_telemetry_metadata_uses_default_mcp_config_path() {
}
#[tokio::test]
async fn plugin_telemetry_metadata_uses_manifest_mcp_server_objects() {
async fn plugin_capability_summary_uses_manifest_mcp_server_objects() {
let codex_home = TempDir::new().unwrap();
let plugin_root = codex_home
.path()
@@ -1195,14 +1270,14 @@ async fn plugin_telemetry_metadata_uses_manifest_mcp_server_objects() {
}"#,
);
let metadata = plugin_telemetry_metadata_from_root(
let summary = plugin_capability_summary_from_root(
&PluginId::parse("counter-sample@test").expect("plugin id should parse"),
&plugin_root.abs(),
)
.await;
assert_eq!(
metadata.capability_summary,
summary,
Some(PluginCapabilitySummary {
config_name: "counter-sample@test".to_string(),
display_name: "counter-sample".to_string(),
+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");
+1 -62
View File
@@ -42,6 +42,7 @@ use codex_sandboxing::SandboxTransformRequest;
use codex_sandboxing::SandboxType;
use codex_sandboxing::SandboxablePreference;
use codex_sandboxing::WindowsSandboxFilesystemOverrides;
pub(crate) use codex_sandboxing::is_likely_sandbox_denied;
#[cfg(test)]
use codex_sandboxing::permission_profile_supports_windows_restricted_token_sandbox;
use codex_sandboxing::resolve_windows_elevated_filesystem_overrides;
@@ -819,68 +820,6 @@ fn finalize_exec_result(
}
}
/// We don't have a fully deterministic way to tell if our command failed
/// because of the sandbox - a command in the user's zshrc file might hit an
/// error, but the command itself might fail or succeed for other reasons.
/// For now, we conservatively check for well known command failure exit codes and
/// also look for common sandbox denial keywords in the command output.
pub(crate) fn is_likely_sandbox_denied(
sandbox_type: SandboxType,
exec_output: &ExecToolCallOutput,
) -> bool {
if sandbox_type == SandboxType::None || exec_output.exit_code == 0 {
return false;
}
// Quick rejects: well-known non-sandbox shell exit codes
// 2: misuse of shell builtins
// 126: permission denied
// 127: command not found
const SANDBOX_DENIED_KEYWORDS: [&str; 7] = [
"operation not permitted",
"permission denied",
"read-only file system",
"seccomp",
"sandbox",
"landlock",
"failed to write file",
];
let has_sandbox_keyword = [
&exec_output.stderr.text,
&exec_output.stdout.text,
&exec_output.aggregated_output.text,
]
.into_iter()
.any(|section| {
let lower = section.to_lowercase();
SANDBOX_DENIED_KEYWORDS
.iter()
.any(|needle| lower.contains(needle))
});
if has_sandbox_keyword {
return true;
}
const QUICK_REJECT_EXIT_CODES: [i32; 3] = [2, 126, 127];
if QUICK_REJECT_EXIT_CODES.contains(&exec_output.exit_code) {
return false;
}
#[cfg(unix)]
{
const SIGSYS_CODE: i32 = libc::SIGSYS;
if sandbox_type == SandboxType::LinuxSeccomp
&& exec_output.exit_code == EXIT_CODE_SIGNAL_BASE + SIGSYS_CODE
{
return true;
}
}
false
}
#[derive(Debug)]
struct RawExecToolCallOutput {
pub exit_status: ExitStatus,
+63 -45
View File
@@ -665,40 +665,23 @@ pub(crate) fn spawn_approval_request_review(
rx
}
/// Runs the guardian in a locked-down reusable review session.
///
/// The guardian itself should not mutate state or trigger further approvals, so
/// it is pinned to a read-only sandbox with `approval_policy = never` and
/// nonessential agent features disabled. When the cached trunk session is idle,
/// later approvals append onto that same guardian conversation to preserve a
/// stable prompt-cache key. If the trunk is already busy, the review runs in an
/// ephemeral fork from the last committed trunk rollout so parallel approvals
/// do not block each other or mutate the cached thread. The trunk is recreated
/// when the effective review-session config changes, and any future compaction
/// must continue to preserve the guardian policy as exact top-level developer
/// context. It may still reuse the parent's managed-network allowlist for
/// read-only checks, but it intentionally runs without inherited exec-policy
/// rules.
async fn run_guardian_review_session_before_deadline(
session: Arc<Session>,
turn: Arc<TurnContext>,
request: GuardianApprovalRequest,
retry_reason: Option<String>,
schema: serde_json::Value,
external_cancel: Option<CancellationToken>,
deadline: Instant,
) -> (GuardianReviewOutcome, GuardianReviewAnalyticsResult) {
pub(super) struct GuardianReviewSessionConfig {
pub(super) spawn_config: crate::config::Config,
model: String,
reasoning_effort: Option<codex_protocol::openai_models::ReasoningEffort>,
default_review_model_id: String,
catalog_contains_auto_review: bool,
model_overridden: bool,
model_override: Option<String>,
}
pub(super) async fn guardian_review_session_config(
session: &Session,
turn: &TurnContext,
) -> anyhow::Result<GuardianReviewSessionConfig> {
let network_proxy = session.services.network_proxy.load_full();
let live_network_config = match network_proxy.as_ref() {
Some(network_proxy) => match network_proxy.proxy().current_cfg().await {
Ok(config) => Some(config),
Err(err) => {
return (
GuardianReviewOutcome::Error(GuardianReviewError::prompt_build(err)),
GuardianReviewAnalyticsResult::without_session(),
);
}
},
Some(network_proxy) => Some(network_proxy.proxy().current_cfg().await?),
None => None,
};
let available_models = session
@@ -750,14 +733,50 @@ async fn run_guardian_review_session_before_deadline(
reasoning_effort,
)
};
let guardian_config = build_guardian_review_session_config(
let spawn_config = build_guardian_review_session_config(
turn.config.as_ref(),
live_network_config.clone(),
live_network_config,
guardian_model.as_str(),
guardian_reasoning_effort.clone(),
);
let guardian_config = match guardian_config {
Ok(config) => config,
)?;
Ok(GuardianReviewSessionConfig {
spawn_config,
model: guardian_model,
reasoning_effort: guardian_reasoning_effort,
default_review_model_id: default_review_model_id.to_string(),
catalog_contains_auto_review: guardian_catalog_contains_auto_review,
model_overridden: guardian_review_model_overridden,
model_override: guardian_review_model_override,
})
}
/// Runs the guardian in a locked-down reusable review session.
///
/// The guardian itself should not mutate state or trigger further approvals, so
/// it is pinned to a read-only sandbox with `approval_policy = never` and
/// nonessential agent features disabled. When the cached trunk session is idle,
/// later approvals append onto that same guardian conversation to preserve a
/// stable prompt-cache key. If the trunk is already busy, the review runs in an
/// ephemeral fork from the last committed trunk rollout so parallel approvals
/// do not block each other or mutate the cached thread. The trunk is recreated
/// when the effective review-session config changes, and any future compaction
/// must continue to preserve the guardian policy as exact top-level developer
/// context. It may still reuse the parent's managed-network allowlist for
/// read-only checks, but it intentionally runs without inherited exec-policy
/// rules.
async fn run_guardian_review_session_before_deadline(
session: Arc<Session>,
turn: Arc<TurnContext>,
request: GuardianApprovalRequest,
retry_reason: Option<String>,
schema: serde_json::Value,
external_cancel: Option<CancellationToken>,
deadline: Instant,
) -> (GuardianReviewOutcome, GuardianReviewAnalyticsResult) {
let session_config = match guardian_review_session_config(session.as_ref(), turn.as_ref()).await
{
Ok(session_config) => session_config,
Err(err) => {
return (
GuardianReviewOutcome::Error(GuardianReviewError::prompt_build(err)),
@@ -765,23 +784,22 @@ async fn run_guardian_review_session_before_deadline(
);
}
};
let (session_outcome, session_analytics_result) = Box::pin(
session
.guardian_review_session
.run_review(GuardianReviewSessionParams {
parent_session: Arc::clone(&session),
parent_turn: turn.clone(),
spawn_config: guardian_config,
spawn_config: session_config.spawn_config,
request,
retry_reason,
schema,
model: guardian_model,
reasoning_effort: guardian_reasoning_effort,
guardian_default_review_model_id: default_review_model_id.to_string(),
guardian_catalog_contains_auto_review,
guardian_review_model_overridden,
guardian_review_model_override,
model: session_config.model,
reasoning_effort: session_config.reasoning_effort,
guardian_default_review_model_id: session_config.default_review_model_id,
guardian_catalog_contains_auto_review: session_config.catalog_contains_auto_review,
guardian_review_model_overridden: session_config.model_overridden,
guardian_review_model_override: session_config.model_override,
reasoning_summary: turn.reasoning_summary,
personality: turn.personality,
external_cancel,
+53 -9
View File
@@ -27,6 +27,7 @@ use codex_protocol::protocol::RolloutItem;
use codex_protocol::protocol::SessionSource;
use codex_protocol::protocol::SubAgentSource;
use codex_protocol::protocol::TokenUsage;
use futures::future::BoxFuture;
use serde_json::Value;
use tokio::sync::Mutex;
use tokio::sync::Semaphore;
@@ -56,6 +57,7 @@ use super::prompt::GuardianTranscriptCursor;
use super::prompt::build_guardian_prompt_items_with_parent_turn;
use super::prompt::guardian_policy_prompt;
use super::prompt::guardian_policy_prompt_with_config;
use super::review::guardian_review_session_config;
const GUARDIAN_INTERRUPT_DRAIN_TIMEOUT: Duration = Duration::from_secs(5);
#[derive(Debug)]
@@ -92,6 +94,7 @@ pub(crate) struct GuardianReviewSessionParams {
#[derive(Default)]
pub(crate) struct GuardianReviewSessionManager {
state: Arc<Mutex<GuardianReviewSessionState>>,
cancellation_token: CancellationToken,
}
#[derive(Default)]
@@ -289,6 +292,42 @@ impl Drop for EphemeralReviewCleanup {
}
impl GuardianReviewSessionManager {
pub(crate) fn initialize(
&self,
parent_session: Arc<Session>,
parent_turn: Arc<TurnContext>,
) -> BoxFuture<'_, anyhow::Result<()>> {
// Boxing breaks the Session::new -> Guardian -> Session::new future recursion.
Box::pin(async move {
let spawn_config = guardian_review_session_config(&parent_session, &parent_turn)
.await?
.spawn_config;
let reuse_key = GuardianReviewSessionReuseKey::from_spawn_config(
&spawn_config,
parent_session.user_instructions().await,
);
let spawn_cancel_token = self.cancellation_token.child_token();
let spawn_cancel_guard = spawn_cancel_token.clone().drop_guard();
let review_session = spawn_guardian_review_session(
&parent_session,
&parent_turn,
spawn_config,
reuse_key,
spawn_cancel_token.clone(),
/*fork_snapshot*/ None,
)
.await?;
// A first review or shutdown may win while eager initialization is in flight;
// install only if neither has happened.
let mut state = self.state.lock().await;
if !spawn_cancel_token.is_cancelled() && state.trunk.is_none() {
state.trunk = Some(Arc::new(review_session));
drop(spawn_cancel_guard.disarm());
}
Ok(())
})
}
pub(crate) async fn trunk_rollout_path(&self) -> Option<PathBuf> {
let trunk = self.state.lock().await.trunk.clone()?;
trunk.codex.session.ensure_rollout_materialized().await;
@@ -302,6 +341,7 @@ impl GuardianReviewSessionManager {
}
pub(crate) async fn shutdown(&self) {
self.cancellation_token.cancel();
let (review_session, ephemeral_reviews) = {
let mut state = self.state.lock().await;
(
@@ -348,13 +388,14 @@ impl GuardianReviewSessionManager {
}
if state.trunk.is_none() {
let spawn_cancel_token = CancellationToken::new();
let spawn_cancel_token = self.cancellation_token.child_token();
let review_session = match run_before_review_deadline_with_cancel(
deadline,
params.external_cancel.as_ref(),
&spawn_cancel_token,
Box::pin(spawn_guardian_review_session(
&params,
&params.parent_session,
&params.parent_turn,
params.spawn_config.clone(),
next_reuse_key.clone(),
spawn_cancel_token.clone(),
@@ -556,7 +597,7 @@ impl GuardianReviewSessionManager {
deadline: tokio::time::Instant,
fork_snapshot: Option<GuardianReviewForkSnapshot>,
) -> (GuardianReviewSessionOutcome, GuardianReviewAnalyticsResult) {
let spawn_cancel_token = CancellationToken::new();
let spawn_cancel_token = self.cancellation_token.child_token();
let mut fork_config = params.spawn_config.clone();
fork_config.ephemeral = true;
let review_session = match run_before_review_deadline_with_cancel(
@@ -564,7 +605,8 @@ impl GuardianReviewSessionManager {
params.external_cancel.as_ref(),
&spawn_cancel_token,
Box::pin(spawn_guardian_review_session(
&params,
&params.parent_session,
&params.parent_turn,
fork_config,
reuse_key,
spawn_cancel_token.clone(),
@@ -605,7 +647,8 @@ impl GuardianReviewSessionManager {
}
async fn spawn_guardian_review_session(
params: &GuardianReviewSessionParams,
parent_session: &Arc<Session>,
parent_turn: &Arc<TurnContext>,
spawn_config: Config,
reuse_key: GuardianReviewSessionReuseKey,
cancel_token: CancellationToken,
@@ -621,10 +664,10 @@ async fn spawn_guardian_review_session(
};
let codex = Box::pin(run_codex_thread_interactive(
spawn_config,
params.parent_session.services.auth_manager.clone(),
params.parent_session.services.models_manager.clone(),
Arc::clone(&params.parent_session),
Arc::clone(&params.parent_turn),
parent_session.services.auth_manager.clone(),
parent_session.services.models_manager.clone(),
Arc::clone(parent_session),
Arc::clone(parent_turn),
cancel_token.clone(),
SubAgentSource::Other(GUARDIAN_REVIEWER_NAME.to_string()),
initial_history,
@@ -1546,6 +1589,7 @@ mod tests {
trunk: Some(Arc::new(review_session)),
ephemeral_reviews: Vec::new(),
})),
..Default::default()
};
drop(tx_event);
+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
@@ -81,7 +81,7 @@ pub(crate) async fn build_prompt_input_from_session(
.await;
if !input.is_empty() {
let response_item = sess.response_item_from_user_input(turn_context.as_ref(), input);
let response_item = sess.response_item_from_user_input(input);
sess.record_conversation_items(turn_context.as_ref(), std::slice::from_ref(&response_item))
.await;
}
+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,
}
}
+9 -34
View File
@@ -1372,17 +1372,11 @@ impl Session {
} = self
.reconstruct_history_from_rollout(turn_context, rollout_items)
.await;
if turn_context
.config
.features
.enabled(Feature::ResizeAllImages)
{
// Keep the recorded rollout unchanged. Prepare its reconstructed history before
// installing it, so legacy images are processed once for this resume or fork and
// will be processed again if the rollout is reconstructed in a future session.
// This meets image resizing requirements without modifying persisted rollouts.
prepare_response_items(&mut history);
}
// Keep the recorded rollout unchanged. Prepare its reconstructed history before
// installing it, so legacy images are processed once for this resume or fork and
// will be processed again if the rollout is reconstructed in a future session.
// This meets image resizing requirements without modifying persisted rollouts.
prepare_response_items(&mut history);
{
let mut state = self.state.lock().await;
state.replace_history(history, reference_context_item);
@@ -2689,13 +2683,7 @@ impl Session {
items: &'a [ResponseItem],
) -> Cow<'a, [ResponseItem]> {
let mut items = Cow::Borrowed(items);
if turn_context
.config
.features
.enabled(Feature::ResizeAllImages)
{
prepare_response_items(items.to_mut());
}
prepare_response_items(items.to_mut());
if turn_context.config.features.enabled(Feature::ItemIds) {
Self::assign_missing_response_item_ids(items)
} else {
@@ -2734,23 +2722,10 @@ impl Session {
items
}
pub(crate) fn response_item_from_user_input(
&self,
turn_context: &TurnContext,
input: Vec<UserInput>,
) -> ResponseItem {
let local_image_preparation = if turn_context
.config
.features
.enabled(Feature::ResizeAllImages)
{
LocalImagePreparation::Defer
} else {
LocalImagePreparation::Process
};
pub(crate) fn response_item_from_user_input(&self, input: Vec<UserInput>) -> ResponseItem {
ResponseItem::from(ResponseInputItem::from_user_input(
input,
local_image_preparation,
LocalImagePreparation::Defer,
))
}
@@ -3666,7 +3641,7 @@ impl Session {
// Persist the user message to history, but emit the turn item from `UserInput` so
// UI-only `text_elements` are preserved. `ResponseItem::Message` does not carry
// those spans, and `record_response_item_and_emit_turn_item` would drop them.
let response_item = self.response_item_from_user_input(turn_context, input.to_vec());
let response_item = self.response_item_from_user_input(input.to_vec());
self.record_conversation_items(turn_context, std::slice::from_ref(&response_item))
.await;
let mut user_message_item = UserMessageItem::new(input);
@@ -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,
}
}
-1
View File
@@ -1217,7 +1217,6 @@ impl Session {
let mut state = sess.state.lock().await;
state.queue_pending_session_start_source(session_start_source);
}
Ok(sess)
}
.await;
+29 -38
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();
@@ -1694,12 +1693,11 @@ async fn record_initial_history_reconstructs_resumed_transcript() {
}
#[tokio::test]
async fn resize_all_images_prepares_failures_before_history_insertion() {
async fn prepares_image_failures_before_history_insertion() {
let (session, turn_context, _rx) = make_session_and_context_with_auth_and_config_and_rx(
CodexAuth::from_api_key("Test API Key"),
Vec::new(),
|config| {
let _ = config.features.enable(Feature::ResizeAllImages);
let _ = config.features.enable(Feature::ItemIds);
},
)
@@ -1723,7 +1721,7 @@ async fn resize_all_images_prepares_failures_before_history_insertion() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
session
@@ -1758,21 +1756,14 @@ async fn resize_all_images_prepares_failures_before_history_insertion() {
]),
success: Some(true),
},
metadata: None,
internal_chat_message_metadata_passthrough: None,
}];
assert_eq!(history.raw_items(), expected.as_slice());
}
#[tokio::test]
async fn resize_all_images_prepares_resumed_history_before_installing_it() {
let (session, _turn_context, _rx) = make_session_and_context_with_auth_and_config_and_rx(
CodexAuth::from_api_key("Test API Key"),
Vec::new(),
|config| {
let _ = config.features.enable(Feature::ResizeAllImages);
},
)
.await;
async fn prepares_resumed_history_before_installing_it() {
let (session, _turn_context) = make_session_and_context().await;
let resumed_item = ResponseItem::Message {
id: None,
role: "user".to_string(),
@@ -1786,7 +1777,7 @@ async fn resize_all_images_prepares_resumed_history_before_installing_it() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
};
session
@@ -1811,7 +1802,7 @@ async fn resize_all_images_prepares_resumed_history_before_installing_it() {
},
],
phase: None,
metadata: None,
internal_chat_message_metadata_passthrough: None,
}]
);
}
@@ -7931,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,
)
@@ -8184,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 {
@@ -8241,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 {
@@ -8407,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))
@@ -9006,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),
@@ -9439,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;
@@ -9698,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),
@@ -9826,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())
@@ -9911,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),
@@ -9926,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),
@@ -9958,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),
@@ -9973,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),
@@ -10005,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),
@@ -10020,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),
@@ -10166,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,
+10 -7
View File
@@ -656,13 +656,16 @@ async fn build_skills_and_plugins(
sess.services
.analytics_events_client
.track_app_mentioned(tracking.clone(), mentioned_app_invocations);
for plugin in mentioned_plugins
.iter()
.filter_map(crate::plugins::PluginCapabilitySummary::telemetry_metadata)
{
sess.services
.analytics_events_client
.track_plugin_used(tracking.clone(), plugin);
for summary in &mentioned_plugins {
if let Some(plugin) = sess
.services
.plugins_manager
.telemetry_metadata_for_capability_summary(summary)
{
sess.services
.analytics_events_client
.track_plugin_used(tracking.clone(), plugin);
}
}
let mut injection_items: Vec<ResponseItem> = match injected_host_skill_prompts {
+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,
}
}
+14 -1
View File
@@ -10,6 +10,7 @@ use tracing::instrument;
use tracing::warn;
use crate::client::ModelClientSession;
use crate::guardian::routes_approval_to_guardian;
use crate::responses_metadata::CodexResponsesRequestKind;
use crate::session::INITIAL_SUBMIT_ID;
use crate::session::session::Session;
@@ -242,6 +243,19 @@ async fn schedule_startup_prewarm_inner(
prewarm_started_at.elapsed(),
/*status*/ None,
);
if routes_approval_to_guardian(&startup_turn_context) {
let guardian_session = Arc::clone(&session);
let guardian_parent_turn = Arc::clone(&startup_turn_context);
drop(tokio::spawn(async move {
if let Err(err) = guardian_session
.guardian_review_session
.initialize(Arc::clone(&guardian_session), guardian_parent_turn)
.await
{
warn!("failed to initialize guardian review session: {err:#}");
}
}));
}
let startup_cancellation_token = CancellationToken::new();
let built_tools_started_at = Instant::now();
let startup_router = built_tools(
@@ -295,6 +309,5 @@ async fn schedule_startup_prewarm_inner(
websocket_warmup_started_at.elapsed(),
/*status*/ None,
);
Ok(client_session)
}
+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 -25
View File
@@ -1,4 +1,3 @@
use codex_features::Feature;
use codex_protocol::items::ImageViewItem;
use codex_protocol::items::TurnItem;
use codex_protocol::models::DEFAULT_IMAGE_DETAIL;
@@ -8,9 +7,7 @@ use codex_protocol::models::FunctionCallOutputPayload;
use codex_protocol::models::ImageDetail;
use codex_protocol::models::ResponseInputItem;
use codex_protocol::openai_models::InputModality;
use codex_utils_image::PromptImageMode;
use codex_utils_image::data_url_from_bytes;
use codex_utils_image::load_for_prompt_bytes;
use serde::Deserialize;
use crate::function_tool::FunctionCallError;
@@ -195,24 +192,8 @@ impl ViewImageHandler {
DEFAULT_IMAGE_DETAIL
};
let image_url = if turn.config.features.enabled(Feature::ResizeAllImages) {
// The history insertion path owns image decoding and resizing when this is enabled.
data_url_from_bytes("application/octet-stream", &file_bytes)
} else {
let image_mode = if use_original_detail {
PromptImageMode::Original
} else {
PromptImageMode::ResizeToFit
};
load_for_prompt_bytes(abs_path.as_path(), file_bytes, image_mode)
.map_err(|error| {
FunctionCallError::RespondToModel(format!(
"unable to process image at `{}`: {error}",
abs_path.display()
))
})?
.into_data_url()
};
// The history insertion path owns image decoding and resizing.
let image_url = data_url_from_bytes("application/octet-stream", &file_bytes);
let item = TurnItem::ImageView(ImageViewItem {
id: call_id,
@@ -420,9 +401,6 @@ mod tests {
})
.await;
let Err(FunctionCallError::RespondToModel(message)) = result else {
panic!("expected image processing error");
};
assert!(message.contains("unable to process image"), "{message}");
result.expect("explicit high detail should be accepted");
}
}
+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,
}
));
}
+9 -11
View File
@@ -228,6 +228,7 @@ impl BlockingTerminateExecProcess {
exit_code: None,
closed: false,
failure: None,
sandbox_denied: false,
})
}
@@ -286,17 +287,14 @@ async fn blocking_terminate_unified_process(
) -> anyhow::Result<Arc<UnifiedExecProcess>> {
let (wake_tx, _wake_rx) = watch::channel(0);
Ok(Arc::new(
UnifiedExecProcess::from_exec_server_started(
StartedExecProcess {
process: Arc::new(BlockingTerminateExecProcess {
process_id: process_id.to_string().into(),
terminate_started,
allow_terminate,
wake_tx,
}),
},
SandboxType::None,
)
UnifiedExecProcess::from_exec_server_started(StartedExecProcess {
process: Arc::new(BlockingTerminateExecProcess {
process_id: process_id.to_string().into(),
terminate_started,
allow_terminate,
wake_tx,
}),
})
.await?,
))
}
+15 -4
View File
@@ -285,8 +285,9 @@ impl UnifiedExecProcess {
&self,
text: &str,
) -> Result<(), UnifiedExecError> {
let executor_reported_denial = self.state_rx.borrow().sandbox_denied;
let sandbox_type = self.sandbox_type();
if sandbox_type == SandboxType::None || !self.has_exited() {
if !self.has_exited() || (!executor_reported_denial && sandbox_type == SandboxType::None) {
return Ok(());
}
@@ -297,7 +298,7 @@ impl UnifiedExecProcess {
aggregated_output: StreamOutput::new(text.to_string()),
..Default::default()
};
if is_likely_sandbox_denied(sandbox_type, &exec_output) {
if executor_reported_denial || is_likely_sandbox_denied(sandbox_type, &exec_output) {
let snippet = formatted_truncate_text(
text,
TruncationPolicy::Tokens(UNIFIED_EXEC_OUTPUT_MAX_TOKENS),
@@ -374,10 +375,13 @@ impl UnifiedExecProcess {
pub(super) async fn from_exec_server_started(
started: StartedExecProcess,
sandbox_type: SandboxType,
) -> Result<Self, UnifiedExecError> {
let process_handle = ProcessHandle::ExecServer(Arc::clone(&started.process));
let mut managed = Self::new(process_handle, sandbox_type, /*spawn_lifecycle*/ None);
let mut managed = Self::new(
process_handle,
SandboxType::None,
/*spawn_lifecycle*/ None,
);
let output_handles = managed.output_handles();
managed.output_task = Some(Self::spawn_exec_server_output_task(
started,
@@ -437,6 +441,7 @@ impl UnifiedExecProcess {
exit_code,
closed,
failure,
sandbox_denied,
} = response;
for chunk in chunks {
@@ -457,6 +462,12 @@ impl UnifiedExecProcess {
break;
}
if sandbox_denied {
let mut state = state_tx.borrow().clone();
state.sandbox_denied = true;
let _ = state_tx.send_replace(state);
}
if exited {
let state = state_tx.borrow().clone();
let _ = state_tx.send_replace(state.exited(exit_code));
@@ -10,6 +10,7 @@ use tokio::sync::watch;
use tokio::time::Duration;
use tokio::time::Instant;
use tokio_util::sync::CancellationToken;
use uuid::Uuid;
use crate::codex_thread::BackgroundTerminalInfo;
use crate::exec_env::CODEX_THREAD_ID_ENV_VAR;
@@ -157,8 +158,14 @@ fn exec_server_params_for_request(
tty: bool,
) -> codex_exec_server::ExecParams {
let (env_policy, env) = exec_server_env_for_request(request);
// Sandbox retries reuse the unified-exec ID but start a distinct executor process.
let exec_server_process_id = if request.exec_server_sandbox.is_some() {
format!("{process_id}-{}", Uuid::new_v4())
} else {
process_id.to_string()
};
codex_exec_server::ExecParams {
process_id: exec_server_process_id(process_id).into(),
process_id: exec_server_process_id.into(),
argv: request.command.clone(),
cwd: request.cwd.clone(),
env_policy,
@@ -198,10 +205,6 @@ impl Drop for InitialExecCommandGuard {
}
}
fn exec_server_process_id(process_id: i32) -> String {
process_id.to_string()
}
async fn unregister_network_approval_for_entry(entry: &ProcessEntry) {
if let Some(network_approval) = entry.network_approval.as_ref()
&& let Some(session) = entry.session.upgrade()
@@ -1041,7 +1044,7 @@ impl UnifiedExecProcessManager {
.await
.map_err(|err| UnifiedExecError::create_process(err.to_string()))?;
spawn_lifecycle.after_spawn();
return UnifiedExecProcess::from_exec_server_started(started, request.sandbox).await;
return UnifiedExecProcess::from_exec_server_started(started).await;
}
// TODO(anp): Keep PathUri through the local PTY/process launch boundary.
@@ -76,7 +76,7 @@ fn exec_server_params_use_path_uri_and_env_policy_overlay_contract() {
codex_protocol::permissions::FileSystemSandboxPolicy::unrestricted();
let network_sandbox_policy = codex_protocol::permissions::NetworkSandboxPolicy::Restricted;
let permission_profile = codex_protocol::models::PermissionProfile::Disabled;
let request = ExecRequest {
let mut request = ExecRequest {
command: vec!["bash".to_string(), "-lc".to_string(), "true".to_string()],
cwd: cwd.clone().into(),
env: HashMap::from([
@@ -106,7 +106,7 @@ fn exec_server_params_use_path_uri_and_env_policy_overlay_contract() {
windows_sandbox_workspace_roots: vec![cwd],
windows_sandbox_level: codex_protocol::config_types::WindowsSandboxLevel::Disabled,
windows_sandbox_private_desktop: false,
permission_profile,
permission_profile: permission_profile.clone(),
file_system_sandbox_policy,
network_sandbox_policy,
windows_sandbox_filesystem_overrides: None,
@@ -128,11 +128,16 @@ fn exec_server_params_use_path_uri_and_env_policy_overlay_contract() {
("CODEX_THREAD_ID".to_string(), "thread-1".to_string()),
])
);
}
#[test]
fn exec_server_process_id_matches_unified_exec_process_id() {
assert_eq!(exec_server_process_id(/*process_id*/ 4321), "4321");
request.exec_server_sandbox = Some(
codex_exec_server::FileSystemSandboxContext::from_permission_profile(permission_profile),
);
let first =
exec_server_params_for_request(/*process_id*/ 123, &request, /*tty*/ true);
let second =
exec_server_params_for_request(/*process_id*/ 123, &request, /*tty*/ true);
assert!(first.process_id.as_str().starts_with("123-"));
assert!(second.process_id.as_str().starts_with("123-"));
assert_ne!(first.process_id, second.process_id);
}
#[cfg(windows)]
@@ -3,6 +3,7 @@ pub(crate) struct ProcessState {
pub(crate) has_exited: bool,
pub(crate) exit_code: Option<i32>,
pub(crate) failure_message: Option<String>,
pub(crate) sandbox_denied: bool,
}
impl ProcessState {
@@ -11,6 +12,7 @@ impl ProcessState {
has_exited: true,
exit_code,
failure_message: self.failure_message.clone(),
sandbox_denied: self.sandbox_denied,
}
}
@@ -19,6 +21,7 @@ impl ProcessState {
has_exited: true,
exit_code: self.exit_code,
failure_message: Some(message),
sandbox_denied: self.sandbox_denied,
}
}
}
@@ -10,7 +10,6 @@ use codex_exec_server::ReadResponse;
use codex_exec_server::StartedExecProcess;
use codex_exec_server::WriteResponse;
use codex_exec_server::WriteStatus;
use codex_sandboxing::SandboxType;
use pretty_assertions::assert_eq;
use std::collections::VecDeque;
use std::sync::Arc;
@@ -40,6 +39,7 @@ impl MockExecProcess {
exit_code: None,
closed: false,
failure: None,
sandbox_denied: false,
}))
}
@@ -103,7 +103,7 @@ async fn remote_process(
}),
};
UnifiedExecProcess::from_exec_server_started(started, SandboxType::None)
UnifiedExecProcess::from_exec_server_started(started)
.await
.expect("remote process should start")
}
@@ -190,6 +190,7 @@ async fn remote_process_waits_for_early_exit_event() {
exit_code: Some(17),
closed: true,
failure: None,
sandbox_denied: false,
}])),
terminate_error: None,
wake_tx: wake_tx.clone(),
@@ -201,7 +202,7 @@ async fn remote_process_waits_for_early_exit_event() {
let _ = wake_tx.send(1);
});
let process = UnifiedExecProcess::from_exec_server_started(started, SandboxType::None)
let process = UnifiedExecProcess::from_exec_server_started(started)
.await
.expect("remote process should observe early exit");
+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
+25 -24
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,
}),
},
];
@@ -860,7 +861,7 @@ async fn resume_replays_legacy_js_repl_image_rollout_shapes() {
async fn resume_replays_image_tool_outputs_with_detail() {
skip_if_no_network!();
let image_url = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEAAUAmJaACdLoB+AADsAD+8ut//NgVzXPv9//S4P0uD9Lg/9KQAAA=";
let image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
let function_call_id = "view-image-call";
let custom_call_id = "js-repl-call";
let thread_id = ThreadId::default();
@@ -888,9 +889,9 @@ async fn resume_replays_image_tool_outputs_with_detail() {
id: None,
name: "view_image".to_string(),
namespace: None,
arguments: "{\"path\":\"/tmp/example.webp\"}".to_string(),
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 -14
View File
@@ -2681,7 +2681,7 @@ async fn code_mode_can_output_images_via_global_helper() -> Result<()> {
&server,
"use exec to return images",
r#"
image("data:image/png;base64,AAA");
image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==");
"#,
)
.await?;
@@ -2706,7 +2706,7 @@ image("data:image/png;base64,AAA");
items[1],
serde_json::json!({
"type": "input_image",
"image_url": "data:image/png;base64,AAA",
"image_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==",
"detail": "high"
}),
);
@@ -2715,17 +2715,14 @@ image("data:image/png;base64,AAA");
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn resize_all_images_replaces_malformed_code_mode_image() -> Result<()> {
async fn code_mode_replaces_malformed_image() -> Result<()> {
skip_if_no_network!(Ok(()));
let server = responses::start_mock_server().await;
let (_test, second_mock) = run_code_mode_turn_with_config(
let (_test, second_mock) = run_code_mode_turn(
&server,
"use exec to return an image",
r#"image("data:image/png;base64,AAA");"#,
|config| {
let _ = config.features.enable(Feature::ResizeAllImages);
},
)
.await?;
@@ -2746,7 +2743,7 @@ async fn resize_all_images_replaces_malformed_code_mode_image() -> Result<()> {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn resize_all_images_resizes_explicit_original_code_mode_image() -> Result<()> {
async fn code_mode_resizes_explicit_original_image() -> Result<()> {
skip_if_no_network!(Ok(()));
let original_dimensions = (6401, 100);
@@ -2772,12 +2769,7 @@ async fn resize_all_images_resizes_explicit_original_code_mode_image() -> Result
"use exec to return a large original-detail image",
&code,
"gpt-5.3-codex",
|config| {
config
.features
.enable(Feature::ResizeAllImages)
.expect("resize_all_images should be enabled");
},
|_| {},
)
.await?;
+7 -7
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 =
@@ -4403,7 +4403,7 @@ async fn snapshot_request_shape_pre_turn_compaction_including_incoming_user_mess
)
.await
.expect("override thread settings");
let image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNgYAAAAAMAASsJTYQAAAAASUVORK5CYII="
let image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg=="
.to_string();
codex
.submit(Op::UserInput {
+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(),
@@ -42,9 +42,11 @@ use wiremock::matchers::path;
const TINY_PNG_BYTES: &[u8] = &[
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0,
0, 0, 31, 21, 196, 137, 0, 0, 0, 11, 73, 68, 65, 84, 120, 156, 99, 96, 0, 2, 0, 0, 5, 0, 1,
122, 94, 171, 63, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130,
0, 0, 31, 21, 196, 137, 0, 0, 0, 13, 73, 68, 65, 84, 120, 156, 99, 248, 207, 192, 240, 31, 0,
5, 0, 1, 255, 137, 153, 61, 29, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130,
];
const TINY_PNG_BASE64: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
const TINY_PNG_DATA_URL: &str = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
fn image_generation_extensions(auth: &CodexAuth) -> Arc<ExtensionRegistry<Config>> {
let auth_manager = codex_core::test_support::auth_manager_from_auth(auth.clone());
@@ -148,7 +150,7 @@ async fn extension_tool_uses_granted_turn_permissions() -> Result<()> {
.and(path("/v1/images/edits"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"created": 1,
"data": [{"b64_json": "cG5n"}],
"data": [{"b64_json": TINY_PNG_BASE64}],
})))
.expect(1)
.mount(&server)
@@ -299,7 +301,7 @@ async fn extension_tool_uses_granted_turn_permissions() -> Result<()> {
let output = request.function_call_output(image_call_id);
let image = &output["output"][0];
assert_eq!(image["type"], "input_image");
assert_eq!(image["image_url"], "data:image/png;base64,cG5n");
assert_eq!(image["image_url"], TINY_PNG_DATA_URL);
Ok(())
}
@@ -17,6 +17,7 @@ use core_test_support::responses::ev_response_created;
use core_test_support::responses::mount_sse_sequence;
use core_test_support::responses::sse;
use core_test_support::responses::start_mock_server;
use core_test_support::responses::start_websocket_server;
use core_test_support::skip_if_no_network;
use core_test_support::skip_if_sandbox;
use core_test_support::test_codex::local_selections;
@@ -30,6 +31,85 @@ use std::os::unix::fs::PermissionsExt;
use std::time::Duration;
use tempfile::TempDir;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn guardian_session_prewarms_and_is_reused_for_first_review() -> Result<()> {
skip_if_no_network!(Ok(()));
let tool_args = json!({
"cmd": "true",
"sandbox_permissions": SandboxPermissions::RequireEscalated,
"justification": "Exercise Guardian approval routing.",
})
.to_string();
let server = start_websocket_server(vec![
vec![vec![ev_response_created("warm-1"), ev_completed("warm-1")]],
vec![vec![ev_response_created("warm-2"), ev_completed("warm-2")]],
vec![vec![
ev_response_created("approval-request"),
ev_function_call("approval-call", "exec_command", &tool_args),
ev_completed("approval-request"),
]],
vec![vec![
ev_response_created("guardian-review"),
ev_completed("guardian-review"),
]],
])
.await;
let mut builder = test_codex().with_config(|config| {
config.permissions.approval_policy = Constrained::allow_any(AskForApproval::OnRequest);
config.approvals_reviewer = ApprovalsReviewer::AutoReview;
});
let test = builder.build_with_websocket_server(&server).await?;
let (first, second) = tokio::time::timeout(Duration::from_secs(5), async {
tokio::join!(
server.wait_for_request(/*connection_index*/ 0, /*request_index*/ 0),
server.wait_for_request(/*connection_index*/ 1, /*request_index*/ 0)
)
})
.await?;
let prewarm_requests = [first.body_json(), second.body_json()];
let guardian_prewarm = prewarm_requests
.iter()
.find(|request| {
request["client_metadata"]["x-openai-subagent"].as_str() == Some("guardian")
})
.expect("guardian startup prewarm request");
assert_eq!(guardian_prewarm["generate"].as_bool(), Some(false));
let guardian_thread_id = guardian_prewarm["client_metadata"]["thread_id"]
.as_str()
.expect("guardian thread id");
test.codex
.submit(
vec![UserInput::Text {
text: "run a command that requires Guardian review".into(),
text_elements: Vec::new(),
}]
.into(),
)
.await?;
let guardian_review = tokio::time::timeout(
Duration::from_secs(5),
server.wait_for_request(/*connection_index*/ 3, /*request_index*/ 0),
)
.await?
.body_json();
assert_eq!(
guardian_review["client_metadata"]["x-openai-subagent"].as_str(),
Some("guardian")
);
assert_eq!(
guardian_review["client_metadata"]["thread_id"].as_str(),
Some(guardian_thread_id)
);
assert_eq!(guardian_review.get("generate"), None);
test.codex.shutdown_and_wait().await?;
server.shutdown().await;
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn guardian_review_session_does_not_inherit_legacy_notify() -> Result<()> {
skip_if_no_network!(Ok(()));
+3 -3
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);
@@ -200,7 +200,7 @@ async fn drag_drop_image_persists_rollout_request_shape() -> anyhow::Result<()>
..
} = test_codex().build(&server).await?;
let image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=".to_string();
let image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==".to_string();
let response = sse(vec![
ev_response_created("resp-1"),
@@ -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);
+1 -1
View File
@@ -506,7 +506,7 @@ async fn model_change_from_image_to_text_strips_prior_image_content() -> Result<
let _ = models_manager
.list_models(RefreshStrategy::OnlineIfUncached)
.await;
let image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNgYAAAAAMAASsJTYQAAAAASUVORK5CYII="
let image_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg=="
.to_string();
test.codex
@@ -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,
}),
]
})
+151 -1
View File
@@ -87,6 +87,7 @@ async fn submit_turn_with_approval_and_environments(
test: &TestCodex,
prompt: &str,
environments: Vec<TurnEnvironmentSelection>,
approval_policy: AskForApproval,
) -> Result<()> {
let turn_environment_selections = codex_protocol::protocol::TurnEnvironmentSelections::new(
test.config.cwd.clone(),
@@ -103,7 +104,7 @@ async fn submit_turn_with_approval_and_environments(
additional_context: Default::default(),
thread_settings: codex_protocol::protocol::ThreadSettingsOverrides {
environments: Some(turn_environment_selections),
approval_policy: Some(AskForApproval::OnRequest),
approval_policy: Some(approval_policy),
approvals_reviewer: Some(ApprovalsReviewer::User),
sandbox_policy: Some(SandboxPolicy::new_read_only_policy()),
collaboration_mode: Some(codex_protocol::config_types::CollaborationMode {
@@ -312,6 +313,151 @@ async fn explicit_remote_shell_runs_in_remote_cwd() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn remote_sandbox_denial_requests_approval_and_retries() -> Result<()> {
skip_if_no_network!(Ok(()));
skip_if_wine_exec!(Ok(()), "requires the Docker-backed POSIX executor");
let Some(_remote_env) = get_remote_test_env() else {
return Ok(());
};
const CALL_ID: &str = "remote-sandbox-denial";
const CONTENTS: &str = "remote sandbox retry succeeded";
let server = start_mock_server().await;
let test = unified_exec_test(&server).await?;
let nonce = SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis();
let remote_cwd = PathBuf::from(format!("/tmp/codex-remote-denial-cwd-{nonce}")).abs();
let target_path = PathBuf::from(format!("/tmp/codex-remote-denial-target-{nonce}")).abs();
let remote_cwd_uri = PathUri::from_path(&remote_cwd)?;
let target_uri = PathUri::from_path(&target_path)?;
test.fs()
.create_directory(
&remote_cwd_uri,
CreateDirectoryOptions { recursive: true },
/*sandbox*/ None,
)
.await?;
test.fs()
.remove(
&target_uri,
RemoveOptions {
recursive: false,
force: true,
},
/*sandbox*/ None,
)
.await?;
let command = format!("printf {CONTENTS:?} > {target_path:?} && cat {target_path:?}");
let response_mock = mount_sse_sequence(
&server,
vec![
sse(vec![
ev_response_created("resp-remote-denial-1"),
ev_function_call(
CALL_ID,
"exec_command",
&json!({
"shell": "/bin/sh",
"cmd": command,
"login": false,
"yield_time_ms": 5_000,
"environment_id": REMOTE_ENVIRONMENT_ID,
})
.to_string(),
),
ev_completed("resp-remote-denial-1"),
]),
sse(vec![
ev_response_created("resp-remote-denial-2"),
ev_assistant_message("msg-remote-denial", "done"),
ev_completed("resp-remote-denial-2"),
]),
],
)
.await;
submit_turn_with_approval_and_environments(
&test,
"retry a sandbox-denied command in the remote environment",
vec![TurnEnvironmentSelection {
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
cwd: PathUri::from_abs_path(&remote_cwd),
}],
AskForApproval::OnFailure,
)
.await?;
let event = wait_for_event(&test.codex, |event| {
matches!(
event,
EventMsg::ExecApprovalRequest(_) | EventMsg::TurnComplete(_)
)
})
.await;
let EventMsg::ExecApprovalRequest(approval) = event else {
panic!("expected remote sandbox approval before completion: {event:?}");
};
assert_eq!(approval.call_id, CALL_ID);
assert_eq!(
approval.environment_id.as_deref(),
Some(REMOTE_ENVIRONMENT_ID)
);
assert_eq!(
approval.reason.as_deref(),
Some("command failed; retry without sandbox?")
);
test.codex
.submit(Op::ExecApproval {
id: approval.effective_approval_id(),
turn_id: None,
decision: ReviewDecision::Approved,
})
.await?;
wait_for_event(&test.codex, |event| {
matches!(event, EventMsg::TurnComplete(_))
})
.await;
assert!(
response_mock
.function_call_output_text(CALL_ID)
.is_some_and(|output| output.contains(CONTENTS)),
"approved retry should return the remote command output"
);
assert_eq!(
test.fs()
.read_file_text(&target_uri, /*sandbox*/ None)
.await?,
CONTENTS
);
test.fs()
.remove(
&target_uri,
RemoveOptions {
recursive: false,
force: true,
},
/*sandbox*/ None,
)
.await?;
test.fs()
.remove(
&remote_cwd_uri,
RemoveOptions {
recursive: true,
force: true,
},
/*sandbox*/ None,
)
.await?;
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn deferred_executor_does_not_duplicate_initial_environment_context() -> Result<()> {
let server = start_mock_server().await;
@@ -834,6 +980,7 @@ async fn remote_request_permissions_grant_unblocks_later_remote_exec() -> Result
cwd: PathUri::from_abs_path(&remote_cwd),
},
],
AskForApproval::OnRequest,
)
.await?;
@@ -1115,6 +1262,7 @@ async fn apply_patch_approvals_are_remembered_per_environment() -> Result<()> {
&test,
"apply patch in local environment",
environments.clone(),
AskForApproval::OnRequest,
)
.await?;
let approval = expect_patch_approval(&test, "call-local").await;
@@ -1134,6 +1282,7 @@ async fn apply_patch_approvals_are_remembered_per_environment() -> Result<()> {
&test,
"apply patch in remote environment",
environments.clone(),
AskForApproval::OnRequest,
)
.await?;
let approval = expect_patch_approval(&test, "call-remote").await;
@@ -1158,6 +1307,7 @@ async fn apply_patch_approvals_are_remembered_per_environment() -> Result<()> {
&test,
"apply patch again in remote environment",
environments,
AskForApproval::OnRequest,
)
.await?;
wait_for_completion_without_patch_approval(&test).await;
+1 -1
View File
@@ -55,7 +55,7 @@ fn has_hosted_tool(tools: &[Value], tool_type: &str) -> bool {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn responses_lite_strips_data_image_detail_without_resize_all_images() -> Result<()> {
async fn responses_lite_strips_data_image_detail() -> Result<()> {
skip_if_no_network!(Ok(()));
let server = responses::start_mock_server().await;
+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!({
-5
View File
@@ -24,7 +24,6 @@ use codex_core::config::Config;
use codex_exec_server::CreateDirectoryOptions;
use codex_exec_server::Environment;
use codex_exec_server::HttpRequestParams;
use codex_features::Feature;
use codex_login::CodexAuth;
use codex_mcp::MCP_SANDBOX_STATE_META_CAPABILITY;
use codex_models_manager::manager::RefreshStrategy;
@@ -1455,10 +1454,6 @@ async fn stdio_image_responses_resize_large_image() -> anyhow::Result<()> {
let rmcp_test_server_bin = remote_aware_stdio_server_bin()?;
let fixture = test_codex()
.with_config(move |config| {
config
.features
.enable(Feature::ResizeAllImages)
.expect("resize_all_images should be enabled");
insert_mcp_server(
config,
server_name,
@@ -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",
+1 -1
View File
@@ -474,7 +474,7 @@ async fn mcp_image_output_preserves_image_and_no_text_summary() -> Result<()> {
let rmcp_test_server_bin = stdio_server_bin()?;
// 1x1 PNG data URL
let openai_png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMB/ee9bQAAAABJRU5ErkJggg==";
let openai_png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
let mut builder = test_codex().with_config(move |config| {
let mut servers = config.mcp_servers.get().clone();
+6 -108
View File
@@ -7,7 +7,6 @@ use codex_exec_server::CreateDirectoryOptions;
use codex_exec_server::LOCAL_ENVIRONMENT_ID;
use codex_exec_server::REMOTE_ENVIRONMENT_ID;
use codex_exec_server::RemoveOptions;
use codex_features::Feature;
use codex_login::CodexAuth;
use codex_protocol::config_types::ReasoningSummary;
use codex_protocol::models::PermissionProfile;
@@ -181,15 +180,10 @@ async fn write_workspace_png(
async fn assert_user_turn_local_image_resizes_to(
original_dimensions: (u32, u32),
expected_dimensions: (u32, u32),
resize_policy: TestImageResizePolicy,
) -> anyhow::Result<()> {
let server = start_mock_server().await;
let mut builder = test_codex().with_config(move |config| {
if resize_policy == TestImageResizePolicy::AllImages {
let _ = config.features.enable(Feature::ResizeAllImages);
}
});
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let TestCodex {
codex,
@@ -263,42 +257,25 @@ async fn assert_user_turn_local_image_resizes_to(
Ok(())
}
#[derive(Clone, Copy, Eq, PartialEq)]
enum TestImageResizePolicy {
Legacy,
AllImages,
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn user_turn_with_local_image_attaches_image() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
assert_user_turn_local_image_resizes_to((2304, 864), (2048, 768), TestImageResizePolicy::Legacy)
.await
assert_user_turn_local_image_resizes_to((2304, 864), (2048, 768)).await
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn user_turn_with_vertical_local_image_resizes_to_square_bounds() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
assert_user_turn_local_image_resizes_to(
(1024, 4096),
(512, 2048),
TestImageResizePolicy::Legacy,
)
.await
assert_user_turn_local_image_resizes_to((1024, 4096), (512, 2048)).await
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn resize_all_images_applies_patch_budget_to_local_user_image() -> anyhow::Result<()> {
async fn user_turn_local_image_applies_patch_budget() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
assert_user_turn_local_image_resizes_to(
(2048, 2048),
(1600, 1600),
TestImageResizePolicy::AllImages,
)
.await
assert_user_turn_local_image_resizes_to((2048, 2048), (1600, 1600)).await
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
@@ -1209,11 +1186,10 @@ async fn view_image_tool_errors_when_path_is_directory() -> anyhow::Result<()> {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn view_image_tool_errors_for_non_image_files() -> anyhow::Result<()> {
async fn view_image_tool_turns_invalid_image_into_placeholder() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let TestCodex {
@@ -1222,84 +1198,6 @@ async fn view_image_tool_errors_for_non_image_files() -> anyhow::Result<()> {
..
} = &test;
let rel_path = "assets/example.json";
let abs_path =
write_workspace_file(&test, rel_path, br#"{ "message": "hello" }"#.to_vec()).await?;
let call_id = "view-image-non-image";
let arguments = serde_json::json!({ "path": rel_path }).to_string();
let first_response = sse(vec![
ev_response_created("resp-1"),
ev_function_call(call_id, "view_image", &arguments),
ev_completed("resp-1"),
]);
responses::mount_sse_once(&server, first_response).await;
let second_response = sse(vec![
ev_assistant_message("msg-1", "done"),
ev_completed("resp-2"),
]);
let mock = responses::mount_sse_once(&server, second_response).await;
let session_model = session_configured.model.clone();
codex
.submit(disabled_user_turn(
&test,
vec![UserInput::Text {
text: "please use the view_image tool to read the json file".into(),
text_elements: Vec::new(),
}],
session_model,
))
.await?;
wait_for_event_with_timeout(
codex,
|event| matches!(event, EventMsg::TurnComplete(_)),
VIEW_IMAGE_TURN_COMPLETE_TIMEOUT,
)
.await;
let request = mock.single_request();
assert!(
request.inputs_of_type("input_image").is_empty(),
"non-image file should not produce an input_image message"
);
let (error_text, success) = request
.function_call_output_content_and_success(call_id)
.expect("function_call_output should be present");
assert_eq!(success, None);
let error_text = error_text.expect("error text present");
let expected_error = format!(
"unable to process image at `{}`: unsupported image `application/json`",
abs_path.display()
);
assert!(
error_text.contains(&expected_error),
"error should describe unsupported file type: {error_text}"
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn resize_all_images_turns_invalid_view_image_into_placeholder() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
let server = start_mock_server().await;
let mut builder = test_codex().with_config(|config| {
let _ = config.features.enable(Feature::ResizeAllImages);
});
let test = builder.build_with_remote_env(&server).await?;
let TestCodex {
codex,
session_configured,
..
} = &test;
let rel_path = "assets/invalid-image.json";
write_workspace_file(&test, rel_path, br#"{ "message": "hello" }"#.to_vec()).await?;
let call_id = "view-image-invalid-placeholder";
+2
View File
@@ -926,6 +926,7 @@ impl SessionState {
exit_code: None,
closed: true,
failure: Some(message),
sandbox_denied: false,
}
}
@@ -1869,6 +1870,7 @@ mod tests {
exit_code: None,
closed: false,
failure: None,
sandbox_denied: false,
})
.expect("read response should serialize"),
}),

Some files were not shown because too many files have changed in this diff Show More