Skip to content

function_call_output for send_message_to_thread is persisted without call_id, breaking strict Responses API providers #45914

Open

Description

@Fuyulnk

function_call_output for send_message_to_thread is persisted without call_id, breaking any strict Responses API provider

Summary

Rollout records for async cross-thread tool results (send_message_to_thread, namespace
codex_app) are written as function_call_output items without a call_id field.

OpenAI's own backend tolerates the malformed item. Any provider that strictly deserializes the
Responses API input array rejects the entire request:

Failed to deserialize the JSON body into the target type: input: missing field `call_id`

Because the bad record stays in thread history, the thread becomes permanently unusable on such
providers once that record falls inside the retained context window.

Environment

  • Codex app (bundled codex): 0.154.0-alpha.6.2
    (/Applications/ChatGPT.app/Contents/Resources/codex)
  • Codex CLI: 0.147.0
  • macOS (Darwin 25.6.0), Apple silicon
  • Provider: custom [model_providers.*] entry pointing at an OpenAI-compatible
    /responses endpoint

Observed record

Taken from a rollout at ~/.codex/sessions/<yyyy>/<mm>/<dd>/*.jsonl:

{
  "timestamp": "2026-09-16T...",
  "type": "response_item",
  "payload": {
    "type": "function_call_output",
    "id": "fco_01a06a8e-65c1-7e22-8b84-c42ca9cf1b6c",
    "name": "send_message_to_thread",
    "namespace": "codex_app",
    "output": "<codex_delegation>...</codex_delegation>"
  }
}

call_id is absent. In the same thread, the corresponding calls are well-formed:

function_call         send_message_to_thread   16 items  — all carry call_id
function_call_output  send_message_to_thread    6 items  — none carry call_id

Positionally, these outputs appear at the start of a later turn (immediately following a
turn_context entry) — i.e. they are the async result of a delegation issued in a previous turn.

Scale and date range

Four long-lived threads in one workspace:

thread bad records first occurrence
A 284 2026-08-31 01:33:52
B 164 2026-08-31 08:57:50
C 221 2026-09-08 07:53:04
D 84 2026-09-04 03:55:12
  • Tool attribution in thread A: 281 / 284 are send_message_to_thread (3 have no name).
  • Month distribution in thread A (thread created 2026-07-18):
    2026-07: 0, 2026-08: 7, 2026-09: 277.

Two independent threads both first show the defect on 2026-08-31, which should bracket the
regression window.

Minimal reproduction (API level)

Verified 2026-09-16 against a strict OpenAI-compatible /responses implementation:

POST {base_url}/responses
{
  "model": "...",
  "input": [
    {"type": "message", "role": "user",
     "content": [{"type": "input_text", "text": "hi"}]},
    {"type": "function_call_output", "id": "fco_test", "output": "test"}
  ]
}
→ 400 {"error":{"message":"Failed to deserialize the JSON body into the target type:
                   input: missing field `call_id`", ...}}

Supplying an arbitrary call_id does not help either:

→ 400 {"error":{"message":"No tool call found for tool output with call_id call_test", ...}}

So the fix must produce an output that is paired with a real call, not merely populated.

Expected behaviour

Every function_call_output written to a rollout should carry the call_id of its originating
call. For async results whose originating call is no longer in the retained history, either
re-emit the call or drop the orphan output when constructing the Responses input array.

Impact

  • Once a bad record enters the retained window, the thread fails on every turn and cannot be
    recovered without manual mutation of the rollout files.
  • The async-result path keeps firing, so new bad records accumulate continuously — the
    problem grows with use rather than being a one-off.
  • Users cannot tell which threads are affected until they hit the error; the failure looks like a
    provider fault rather than a history-corruption fault.

Additional notes

  • A codex-side log line exists: Orphan function call output for call id: …, so orphan handling
    is present — it just does not cover the missing field case, which is what breaks strict
    deserializers.
  • Happy to provide redacted rollout excerpts or a script that counts affected records in a
    CODEX_HOME if that would help.

Activity

  1. added
    bug
    app
    custom-model
    subagent
    session
    on Sep 16, 2026
  2. pluto1747-cybr commented on Sep 25, 2026

    @pluto1747-cybr

    Fresh cross-platform reproduction on Codex Desktop 26.917.71314 (still present)

    Environment

    Repro — three routes, all fail on the first turn

    1. create_thread with a one-line prompt → 422
    2. send_message_to_thread to that thread → 422
    3. fork_thread, then send_message_to_thread → 422

    Request ids

    • macOS create_thread: 878daf04-78fb-4e44-8642-d706df6ba2f7
    • Windows create_thread: 467f7001-4874-4505-a971-7755485a6715
    • Windows send_message_to_thread: e63e51b5-4ffa-4c62-89cf-a3fab8553a61
    • Windows fork_thread + send: 57b05ca4-6953-44dd-8938-016a6fab58de

    Rollout evidence (macOS, rollout-2026-09-25T19-13-52-01a0d845-9150-7801-9807-e9b9799e130d.jsonl)

    • line 6: turn_context with multi_agent_version=v1
    • line 8: FunctionCallOutput item keys = id, name, namespace, output, type — no call_id
    • line 9: unexpected status 422 Unprocessable Entity: ... input: missing field 'call_id' ... url: https://api.deepseek.com/responses

    Working control: a thread created manually in the UI can dispatch a subagent successfully on the same build/provider (v1 delivery + child repeats a verification token). The defect appears limited to threads the app creates programmatically (create_thread / send_message_to_thread / fork_thread + send), consistent with the keep_forked_rollout_item analysis in #42088.

    New value here: still present on 26.917.71314, reproduces identically on macOS and Windows, and the manual-UI thread path is a working control.

  3. pluto1747-cybr commented on Oct 14, 2026

    @pluto1747-cybr
  4. kolya182 commented on Oct 14, 2026

    @kolya182

    @etraut-openai @jif-oai Could you help route this issue to the team that owns the app-server and Responses request path?

    I confirmed that this still reproduces with Codex CLI 0.162.1 and a custom Responses provider. Sending a read-only cross-thread message fails before the receiving thread runs:

    Responses field 'input[].call_id' must be a non-empty string.

    The current main source still creates the handoff result as a function_call_output without a call_id, and the custom-provider request path does not convert it. Please triage this report and confirm the owner or fix plan.

  5. MilesBao commented on Nov 7, 2026

    @MilesBao

    Additional evidence from Linux on 2026-11-07: create_thread delegation rejected by a custom Responses provider

    Environment:

    • Linux remote host; Codex Desktop connected to the remote App Server.
    • CLI/App Server version recorded in the affected rollouts: 0.156.1.
    • Model: gpt-6.1-sol through a custom Packy Responses provider and a local forwarding router.
    • Desktop client version was not collected.

    The affected chat was created programmatically with codex_app.create_thread. Its initial rollout contains this standalone item (identifiers and task text redacted):

    {
      "type": "response_item",
      "payload": {
        "type": "function_call_output",
        "id": "fco_REDACTED",
        "name": "create_thread",
        "namespace": "codex_app",
        "output": "<codex_delegation>...redacted handoff...</codex_delegation>"
      }
    }

    There is no call_id on this item and no corresponding function_call in the initial rollout. The session metadata marks it as agent_created_thread.

    Two turns failed with HTTP 400, at approximately 09:11 and 09:27 UTC on November 7. Both errors referenced the same fco_... identifier from the initial delegation:

    No tool call found for function call output with call_id fco_REDACTED.
    type: packy_invalid_request_error
    param: input
    code: invalid_request_error
    

    The chat also executed tools successfully between those failures. Its later rollout contains 22 custom tool calls and 22 outputs, all paired by call_id. Therefore this observation is intermittent; it does not demonstrate failure on every turn.

    The inspected local router changes the model name and forwards the JSON body, without normalizing delegation items. We did not capture the complete outbound payload of the failing request or compare with the first-party backend, so we cannot isolate the exact serialization or upstream validation step.

    The user has moved the task to a manually created chat. We have not performed a controlled reproduction or a patched-client test. A proposed minimal reproduction is to create a chat with a harmless one-line prompt using create_thread, then continue it through a strict Responses provider and inspect the persisted delegation item.

    This appears consistent with #45450 as well as this issue. Please ensure the provider-facing representation supports injected delegation context without requiring an unmatched tool result or dropping the handoff content. Merely inventing a call_id would not establish a matching call.

  6. nscottnichols commented on Nov 23, 2026

    @nscottnichols

    Reproduced on Codex CLI 0.171.0 (Linux) with a custom Responses provider using kimi-k3.1-pro.

    Two incoming codex_tui.send_message_to_thread deliveries persisted as function_call_output records with fco_… IDs, namespace: "codex_tui", and <codex_delegation> output. Neither record had a call_id or a corresponding assistant tool call. Kimi rejected the resumed history because its tool messages could not resolve a tool name.

    features.untrusted_as_tool_output = false prevents the separate goal_objective representation, but did not prevent these cross-thread records.

    I converted only those two positively identified records into user messages containing one input_text item:

    <external_send_message_to_thread>ORIGINAL_OUTPUT</external_send_message_to_thread>
    

    The migration changed fco_… IDs to msg_…, preserved metadata and passthrough fields, invented no call IDs, left genuine paired tool calls unchanged, and preserved unrelated rollout lines byte-for-byte. Validation found no remaining standalone outputs without call_id, and a non-interactive exec resume --ephemeral returned the exact expected response without HTTP 400 or tool calls.

    Current main still constructs tool_output with call_id: None in turn_processor.rs. A provider-facing request-normalization fix would avoid both inventing unmatched call IDs and requiring users to repair rollouts manually. I am preparing a patch that lowers named standalone outputs to external user-text messages for providers that do not support them, while preserving the existing OpenAI representation.

  7. nscottnichols commented on Nov 23, 2026

    @nscottnichols

    Here is a tested reference implementation for maintainers, shared as issue material rather than an external PR.

    Design

    • Adds an opt-out provider capability, supports_standalone_function_call_output, defaulting to true to preserve existing behavior.
    • When disabled, named function_call_output items without call_id are converted only on the request copy, leaving rollout history unchanged.
    • Full text and structured text/image/audio content are preserved. fco_… IDs become msg_… IDs, relevant passthrough metadata is retained, genuine paired tool outputs are untouched, and no call ID is fabricated. Unnamed or encrypted items that cannot be converted losslessly remain unchanged.
    • The capability is preserved through thread-config protobuf serialization and included in the generated config schema.

    For a strict custom provider, the new setting is used as follows (substituting the configured provider ID):

    [model_providers.custom_kimi.capabilities]
    supports_standalone_function_call_output = false

    Based on main commit 1589e80b28536af91aef8c8c1671d4c3c428e571. Eight targeted tests pass with Rust 1.99.1 on Linux:

    • Provider capability default/override resolution
    • TOML parsing
    • Thread-config protobuf roundtrip
    • Four request-lowering cases covering exact text wrapping, structured media, unchanged paired/unnamed/encrypted items, and unchanged original prompt history
    • Generated config-schema fixture verification

    Related coverage and limits

    With supports_standalone_function_call_output = false, the same request-copy normalization should apply to other named, standalone function_call_output sources, including the reports linked below. These are potential regression fixtures, not independently verified producer-level fixes:

    This does not rewrite persisted rollouts; normalization occurs on each outgoing request. It remains conditional on disabling the new provider capability. Unnamed or encrypted outputs are intentionally not converted.

    #60420, involving parallel tool-batch ordering, and #44779, involving tool_search, are separate problems and are not covered by this patch.

    Status checked on 2026-11-23: the reports linked above were open. Related closed examples include #61298 (duplicate), #62054 (not planned), and #62665 (not planned).

    Full reference diff (12 files, 361 insertions)
    diff --git a/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.proto b/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.proto
    index 1e7d72b..cbda01a 100644
    --- a/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.proto
    +++ b/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.proto
    @@ -58,6 +58,7 @@ message ModelProvider {
     
     message ModelProviderCapabilities {
       optional bool cyber_access_programs = 1;
    +  optional bool supports_standalone_function_call_output = 2;
     }
     
     message StringMap {
    diff --git a/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.rs b/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.rs
    index c6e5b16..52e4928 100644
    --- a/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.rs
    +++ b/codex-rs/config/src/thread_config/proto/codex.thread_config.v1.rs
    @@ -92,6 +92,8 @@ pub struct ModelProvider {
     pub struct ModelProviderCapabilities {
         #[prost(bool, optional, tag = "1")]
         pub cyber_access_programs: ::core::option::Option<bool>,
    +    #[prost(bool, optional, tag = "2")]
    +    pub supports_standalone_function_call_output: ::core::option::Option<bool>,
     }
     #[derive(Clone, PartialEq, ::prost::Message)]
     pub struct StringMap {
    diff --git a/codex-rs/config/src/thread_config/remote.rs b/codex-rs/config/src/thread_config/remote.rs
    index d207231..0013970 100644
    --- a/codex-rs/config/src/thread_config/remote.rs
    +++ b/codex-rs/config/src/thread_config/remote.rs
    @@ -200,6 +200,8 @@ fn model_provider_from_proto(
                 .capabilities
                 .map(|capabilities| ModelProviderCapabilities {
                     cyber_access_programs: capabilities.cyber_access_programs,
    +                supports_standalone_function_call_output: capabilities
    +                    .supports_standalone_function_call_output,
                     ..Default::default()
                 }),
             project_id: provider.project_id,
    @@ -255,6 +257,8 @@ fn model_provider_to_proto(
             auth: auth.map(model_provider_auth_to_proto),
             capabilities: capabilities.map(|capabilities| proto::ModelProviderCapabilities {
                 cyber_access_programs: capabilities.cyber_access_programs,
    +            supports_standalone_function_call_output: capabilities
    +                .supports_standalone_function_call_output,
             }),
             wire_api: proto_wire_api(wire_api).into(),
             query_params: query_params.map(proto_string_map),
    @@ -475,6 +479,7 @@ mod tests {
                 Some(ModelProviderCapabilities::default()),
                 Some(ModelProviderCapabilities {
                     cyber_access_programs: Some(false),
    +                supports_standalone_function_call_output: Some(false),
                     ..Default::default()
                 }),
                 Some(ModelProviderCapabilities {
    @@ -521,6 +526,7 @@ mod tests {
                                 ),
                                 capabilities: Some(proto::ModelProviderCapabilities {
                                     cyber_access_programs: Some(true),
    +                                supports_standalone_function_call_output: None,
                                 }),
                                 credential_file: None,
                                 env_key: None,
    diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json
    index 928564e..11b0f26 100644
    --- a/codex-rs/core/config.schema.json
    +++ b/codex-rs/core/config.schema.json
    @@ -3347,6 +3347,10 @@
                 }
               ],
               "description": "Remote context-compaction protocol; omission preserves provider defaults."
    +        },
    +        "supports_standalone_function_call_output": {
    +          "description": "Whether named `function_call_output` items without `call_id` are accepted. When disabled, Codex converts supported standalone outputs to user messages.",
    +          "type": "boolean"
             }
           },
           "type": "object"
    diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs
    index ad30162..91309da 100644
    --- a/codex-rs/core/src/client.rs
    +++ b/codex-rs/core/src/client.rs
    @@ -91,8 +91,12 @@ use codex_protocol::auth::AuthMode;
     use codex_protocol::ThreadId;
     use codex_protocol::config_types::ReasoningSummary as ReasoningSummaryConfig;
     use codex_protocol::config_types::Verbosity as VerbosityConfig;
    +use codex_protocol::models::ContentItem;
    +use codex_protocol::models::FunctionCallOutputBody;
    +use codex_protocol::models::FunctionCallOutputContentItem;
     use codex_protocol::models::ResponseItem;
     use codex_protocol::models::ToolResultBody;
    +use codex_protocol::models::input_text;
     use codex_protocol::openai_models::ModelInfo;
     use codex_protocol::openai_models::ReasoningEffort as ReasoningEffortConfig;
     use codex_protocol::protocol::AuthRecoveryEvent;
    @@ -1298,6 +1302,14 @@ impl ModelClient {
                 prefix.push(instructions);
             }
             input.splice(0..0, prefix);
    +        if !self
    +            .state
    +            .provider
    +            .capabilities()
    +            .supports_standalone_function_call_output
    +        {
    +            lower_named_standalone_function_call_outputs(&mut input);
    +        }
             if !model_info.use_responses_lite {
                 // Only RLite accepts per-content attribution until the Responses API schema expands.
                 for item in &mut input {
    @@ -1732,6 +1744,97 @@ impl Drop for ModelClientSession {
         }
     }
     
    +fn lower_named_standalone_function_call_outputs(input: &mut [ResponseItem]) {
    +    for item in input {
    +        let replacement = match item {
    +            ResponseItem::FunctionCallOutput {
    +                id,
    +                call_id: None,
    +                name: Some(name),
    +                output,
    +                internal_chat_message_metadata_passthrough,
    +                ..
    +            } if !name.is_empty() => {
    +                standalone_output_message_content(name, &output.body).map(|content| {
    +                    let id = id.as_ref().map(|id| {
    +                        id.as_str()
    +                            .strip_prefix("fco_")
    +                            .map(|suffix| ResponseItemId::from_server(format!("msg_{suffix}")))
    +                            .unwrap_or_else(|| id.clone())
    +                    });
    +                    ResponseItem::Message {
    +                        encrypted_content: None,
    +                        status: None,
    +                        id,
    +                        role: "user".to_string(),
    +                        content,
    +                        phase: None,
    +                        internal_chat_message_metadata_passthrough:
    +                            internal_chat_message_metadata_passthrough.clone(),
    +                    }
    +                })
    +            }
    +            _ => None,
    +        };
    +        if let Some(replacement) = replacement {
    +            *item = replacement;
    +        }
    +    }
    +}
    +
    +fn standalone_output_message_content(
    +    name: &str,
    +    body: &FunctionCallOutputBody,
    +) -> Option<Vec<ContentItem>> {
    +    match body {
    +        FunctionCallOutputBody::Text(text) => Some(vec![input_text(format!(
    +            "<external_{name}>{text}</external_{name}>"
    +        ))]),
    +        FunctionCallOutputBody::ContentItems(items) => {
    +            let mut converted = Vec::with_capacity(items.len());
    +            for item in items {
    +                converted.push(match item {
    +                    FunctionCallOutputContentItem::InputText { text } => {
    +                        ContentItem::InputText { text: text.clone() }
    +                    }
    +                    FunctionCallOutputContentItem::InputImage { image, detail } => {
    +                        ContentItem::InputImage {
    +                            image: image.clone(),
    +                            detail: *detail,
    +                        }
    +                    }
    +                    FunctionCallOutputContentItem::InputAudio { audio } => {
    +                        ContentItem::InputAudio {
    +                            audio: audio.clone(),
    +                        }
    +                    }
    +                    FunctionCallOutputContentItem::EncryptedContent { .. } => return None,
    +                });
    +            }
    +            if converted
    +                .iter()
    +                .all(|item| matches!(item, ContentItem::InputText { .. }))
    +            {
    +                let mut text = format!("<external_{name}>");
    +                for item in converted {
    +                    let ContentItem::InputText { text: part } = item else {
    +                        unreachable!("text-only content was checked above");
    +                    };
    +                    text.push_str(&part);
    +                }
    +                text.push_str(&format!("</external_{name}>"));
    +                Some(vec![input_text(text)])
    +            } else {
    +                let mut content = Vec::with_capacity(converted.len() + 2);
    +                content.push(input_text(format!("<external_{name}>")));
    +                content.extend(converted);
    +                content.push(input_text(format!("</external_{name}>")));
    +                Some(content)
    +            }
    +        }
    +    }
    +}
    +
     impl ModelClientSession {
         pub(crate) fn inference_tools_changed(&self, tools: &Arc<[ToolSpec]>) -> bool {
             let previous = self
    diff --git a/codex-rs/core/src/client_tests.rs b/codex-rs/core/src/client_tests.rs
    index bfb3733..e611f05 100644
    --- a/codex-rs/core/src/client_tests.rs
    +++ b/codex-rs/core/src/client_tests.rs
    @@ -12,6 +12,7 @@ use super::X_CODEX_PARENT_THREAD_ID_HEADER;
     use super::X_CODEX_TURN_METADATA_HEADER;
     use super::X_CODEX_WINDOW_ID_HEADER;
     use super::X_OPENAI_SUBAGENT_HEADER;
    +use super::lower_named_standalone_function_call_outputs;
     use super::sampling_result_destination;
     use crate::AttestationContext;
     use crate::AttestationProvider;
    @@ -40,6 +41,7 @@ use codex_model_provider::ProviderUnauthorizedRecovery;
     use codex_model_provider::SharedModelProvider;
     use codex_model_provider::create_model_provider;
     use codex_model_provider_info::CHATGPT_CODEX_BASE_URL;
    +use codex_model_provider_info::ModelProviderCapabilities;
     use codex_model_provider_info::ModelProviderInfo;
     use codex_model_provider_info::WireApi;
     use codex_model_provider_info::create_oss_provider_with_base_url;
    @@ -152,6 +154,193 @@ fn test_model_provider() -> SharedModelProvider {
         test_model_client(SessionSource::Cli).state.provider.clone()
     }
     
    +#[test]
    +fn standalone_output_lowering_preserves_text_passthrough_and_other_items() {
    +    let text = "full delegation ".repeat(2_000);
    +    let standalone: ResponseItem = serde_json::from_value(json!({
    +        "type": "function_call_output",
    +        "id": "fco_standalone",
    +        "name": "send_message_to_thread",
    +        "namespace": "codex_tui",
    +        "output": text.clone(),
    +        "internal_chat_message_metadata_passthrough": {"turn_id": "turn-1"}
    +    }))
    +    .unwrap();
    +    let paired: ResponseItem = serde_json::from_value(json!({
    +        "type": "function_call_output",
    +        "id": "fco_paired",
    +        "call_id": "call-1",
    +        "output": "ordinary result"
    +    }))
    +    .unwrap();
    +    let unnamed: ResponseItem = serde_json::from_value(json!({
    +        "type": "function_call_output",
    +        "id": "fco_unnamed",
    +        "output": "unnamed result"
    +    }))
    +    .unwrap();
    +    let encrypted: ResponseItem = serde_json::from_value(json!({
    +        "type": "function_call_output",
    +        "id": "fco_encrypted",
    +        "name": "private_result",
    +        "output": [{"type": "encrypted_content", "encrypted_content": "ciphertext"}]
    +    }))
    +    .unwrap();
    +    let mut input = vec![
    +        standalone,
    +        paired.clone(),
    +        unnamed.clone(),
    +        encrypted.clone(),
    +    ];
    +
    +    lower_named_standalone_function_call_outputs(&mut input);
    +
    +    assert_eq!(
    +        serde_json::to_value(&input[0]).unwrap(),
    +        json!({
    +            "type": "message",
    +            "id": "msg_standalone",
    +            "role": "user",
    +            "content": [{
    +                "type": "input_text",
    +                "text": format!("<external_send_message_to_thread>{text}</external_send_message_to_thread>")
    +            }],
    +            "internal_chat_message_metadata_passthrough": {"turn_id": "turn-1"}
    +        })
    +    );
    +    assert_eq!(input[1], paired);
    +    assert_eq!(input[2], unnamed);
    +    assert_eq!(input[3], encrypted);
    +}
    +
    +#[test]
    +fn standalone_output_lowering_preserves_structured_media() {
    +    let original: ResponseItem = serde_json::from_value(json!({
    +        "type": "function_call_output",
    +        "id": "fco_structured",
    +        "name": "worker_update",
    +        "output": [
    +            {"type": "input_text", "text": "first"},
    +            {"type": "input_text", "text": "second"},
    +            {"type": "input_image", "image_url": "data:image/png;base64,AA==", "detail": "original"}
    +        ]
    +    }))
    +    .unwrap();
    +    let mut input = vec![original];
    +
    +    lower_named_standalone_function_call_outputs(&mut input);
    +
    +    assert_eq!(
    +        serde_json::to_value(&input[0]).unwrap(),
    +        json!({
    +            "type": "message",
    +            "id": "msg_structured",
    +            "role": "user",
    +            "content": [
    +                {"type": "input_text", "text": "<external_worker_update>"},
    +                {"type": "input_text", "text": "first"},
    +                {"type": "input_text", "text": "second"},
    +                {"type": "input_image", "image_url": "data:image/png;base64,AA==", "detail": "original"},
    +                {"type": "input_text", "text": "</external_worker_update>"}
    +            ]
    +        })
    +    );
    +}
    +
    +#[test]
    +fn standalone_output_lowering_combines_text_only_content_items() {
    +    let original: ResponseItem = serde_json::from_value(json!({
    +        "type": "function_call_output",
    +        "name": "worker_update",
    +        "output": [
    +            {"type": "input_text", "text": "first"},
    +            {"type": "input_text", "text": "second"}
    +        ]
    +    }))
    +    .unwrap();
    +    let mut input = vec![original];
    +
    +    lower_named_standalone_function_call_outputs(&mut input);
    +
    +    assert_eq!(
    +        serde_json::to_value(&input[0]).unwrap(),
    +        json!({
    +            "type": "message",
    +            "role": "user",
    +            "content": [{
    +                "type": "input_text",
    +                "text": "<external_worker_update>firstsecond</external_worker_update>"
    +            }]
    +        })
    +    );
    +}
    +
    +#[test]
    +fn responses_request_honors_standalone_output_provider_capability() -> anyhow::Result<()> {
    +    let standalone: ResponseItem = serde_json::from_value(json!({
    +        "type": "function_call_output",
    +        "id": "fco_delegation",
    +        "name": "send_message_to_thread",
    +        "namespace": "codex_tui",
    +        "output": "<codex_delegation>worker report</codex_delegation>"
    +    }))?;
    +    let prompt = Prompt {
    +        input: vec![standalone.clone()],
    +        ..Default::default()
    +    };
    +    let mut client = test_model_client(SessionSource::Cli);
    +    let responses_metadata = test_responses_metadata_for_client(
    +        &client,
    +        None,
    +        format!("{}:0", client.state.thread_id),
    +        None,
    +        TestCodexResponsesRequestKind::Turn,
    +    );
    +
    +    for supported in [true, false] {
    +        let provider = ModelProviderInfo {
    +            capabilities: Some(ModelProviderCapabilities {
    +                supports_standalone_function_call_output: Some(supported),
    +                ..Default::default()
    +            }),
    +            ..create_oss_provider_with_base_url("https://example.com/v1", WireApi::Responses)
    +        };
    +        Arc::get_mut(&mut client.state)
    +            .expect("test client should have unique session state")
    +            .provider = create_model_provider(provider, None);
    +        let request = client.build_responses_request(
    +            &prompt,
    +            &test_model_info(),
    +            None,
    +            codex_protocol::config_types::ReasoningSummary::None,
    +            None,
    +            &responses_metadata,
    +            false,
    +        )?;
    +        let body = serde_json::to_value(request)?;
    +        let items = body["input"].as_array().unwrap();
    +        if supported {
    +            assert!(items.iter().any(|item| {
    +                item["type"] == "function_call_output" && item["id"] == "fco_delegation"
    +            }));
    +        } else {
    +            assert!(!items.iter().any(|item| {
    +                item["type"] == "function_call_output" && item.get("call_id").is_none()
    +            }));
    +            assert!(items.iter().any(|item| {
    +                item["type"] == "message"
    +                    && item["id"] == "msg_delegation"
    +                    && item["content"] == json!([{
    +                        "type": "input_text",
    +                        "text": "<external_send_message_to_thread><codex_delegation>worker report</codex_delegation></external_send_message_to_thread>"
    +                    }])
    +            }));
    +        }
    +    }
    +    assert_eq!(prompt.input, vec![standalone]);
    +    Ok(())
    +}
    +
     #[test_case::test_case(None; "credential_auth")]
     #[test_case::test_case(Some(RuntimeAuthMode::DualHeader); "dual_header")]
     #[test_case::test_case(Some(RuntimeAuthMode::AssertionOnly); "assertion_only")]
    diff --git a/codex-rs/model-provider-info/src/capabilities.rs b/codex-rs/model-provider-info/src/capabilities.rs
    index 8571bb1..60cd4aa 100644
    --- a/codex-rs/model-provider-info/src/capabilities.rs
    +++ b/codex-rs/model-provider-info/src/capabilities.rs
    @@ -17,6 +17,9 @@ pub struct ModelProviderCapabilities {
         pub cyber_access_programs: Option<bool>,
         /// Whether hosted web search may access the live web.
         pub external_web_access: Option<bool>,
    +    /// Whether named `function_call_output` items without `call_id` are accepted.
    +    /// When disabled, Codex converts supported standalone outputs to user messages.
    +    pub supports_standalone_function_call_output: Option<bool>,
         /// Remote context-compaction protocol; omission preserves provider defaults.
         pub remote_compaction: Option<RemoteCompactionSupport>,
     }
    diff --git a/codex-rs/model-provider-info/src/model_provider_info_tests.rs b/codex-rs/model-provider-info/src/model_provider_info_tests.rs
    index 68b48aa..cb10754 100644
    --- a/codex-rs/model-provider-info/src/model_provider_info_tests.rs
    +++ b/codex-rs/model-provider-info/src/model_provider_info_tests.rs
    @@ -1109,3 +1109,21 @@ fn cyber_access_program_capability_uses_provider_identity_and_explicit_overrides
             }
         }
     }
    +
    +#[test]
    +fn standalone_function_call_output_capability_deserializes_from_toml() {
    +    let provider: ModelProviderInfo = toml::from_str(
    +        r#"
    +        [capabilities]
    +        supports_standalone_function_call_output = false
    +        "#,
    +    )
    +    .unwrap();
    +
    +    assert_eq!(
    +        provider
    +            .capabilities
    +            .and_then(|capabilities| capabilities.supports_standalone_function_call_output),
    +        Some(false)
    +    );
    +}
    diff --git a/codex-rs/model-provider/src/amazon_bedrock/mod.rs b/codex-rs/model-provider/src/amazon_bedrock/mod.rs
    index aceb705..a614cfc 100644
    --- a/codex-rs/model-provider/src/amazon_bedrock/mod.rs
    +++ b/codex-rs/model-provider/src/amazon_bedrock/mod.rs
    @@ -308,6 +308,7 @@ impl ModelProvider for AmazonBedrockModelProvider {
                 image_generation: false,
                 web_search: self.endpoint == BedrockEndpoint::Mantle,
                 external_web_access: false,
    +            supports_standalone_function_call_output: true,
                 remote_compaction: RemoteCompactionSupport::V2,
             }
         }
    @@ -728,6 +729,7 @@ mod tests {
                     image_generation: false,
                     web_search: true,
                     external_web_access: false,
    +                supports_standalone_function_call_output: true,
                     remote_compaction: RemoteCompactionSupport::V2,
                 }
             );
    @@ -747,6 +749,7 @@ mod tests {
                     image_generation: false,
                     web_search: false,
                     external_web_access: false,
    +                supports_standalone_function_call_output: true,
                     remote_compaction: RemoteCompactionSupport::V2,
                 }
             );
    diff --git a/codex-rs/model-provider/src/capabilities.rs b/codex-rs/model-provider/src/capabilities.rs
    index 311a83f..4b7bd27 100644
    --- a/codex-rs/model-provider/src/capabilities.rs
    +++ b/codex-rs/model-provider/src/capabilities.rs
    @@ -15,6 +15,7 @@ pub struct ProviderCapabilities {
         pub image_generation: bool,
         pub web_search: bool,
         pub external_web_access: bool,
    +    pub supports_standalone_function_call_output: bool,
         pub remote_compaction: RemoteCompactionSupport,
     }
     
    @@ -25,6 +26,7 @@ impl Default for ProviderCapabilities {
                 image_generation: true,
                 web_search: true,
                 external_web_access: true,
    +            supports_standalone_function_call_output: true,
                 remote_compaction: RemoteCompactionSupport::Unsupported,
             }
         }
    @@ -47,6 +49,9 @@ impl ProviderCapabilities {
                 external_web_access: overrides
                     .external_web_access
                     .unwrap_or(defaults.external_web_access),
    +            supports_standalone_function_call_output: overrides
    +                .supports_standalone_function_call_output
    +                .unwrap_or(defaults.supports_standalone_function_call_output),
                 remote_compaction: overrides
                     .remote_compaction
                     .unwrap_or(defaults.remote_compaction),
    diff --git a/codex-rs/model-provider/src/capabilities_tests.rs b/codex-rs/model-provider/src/capabilities_tests.rs
    index c22c17f..366b90e 100644
    --- a/codex-rs/model-provider/src/capabilities_tests.rs
    +++ b/codex-rs/model-provider/src/capabilities_tests.rs
    @@ -33,3 +33,29 @@ fn capability_overrides_preserve_unspecified_provider_defaults() {
             );
         }
     }
    +
    +#[test]
    +fn standalone_function_call_output_support_honors_provider_override() {
    +    let supported = create_model_provider(ModelProviderInfo::default(), None);
    +    assert!(
    +        supported
    +            .capabilities()
    +            .supports_standalone_function_call_output
    +    );
    +
    +    let unsupported = create_model_provider(
    +        ModelProviderInfo {
    +            capabilities: Some(ModelProviderCapabilities {
    +                supports_standalone_function_call_output: Some(false),
    +                ..Default::default()
    +            }),
    +            ..Default::default()
    +        },
    +        None,
    +    );
    +    assert!(
    +        !unsupported
    +            .capabilities()
    +            .supports_standalone_function_call_output
    +    );
    +}
    diff --git a/codex-rs/model-provider/src/gcp/mod.rs b/codex-rs/model-provider/src/gcp/mod.rs
    index 0e9038d..bc2a1c8 100644
    --- a/codex-rs/model-provider/src/gcp/mod.rs
    +++ b/codex-rs/model-provider/src/gcp/mod.rs
    @@ -84,6 +84,7 @@ impl ModelProvider for GcpModelProvider {
                 image_generation: false,
                 web_search: false,
                 external_web_access: false,
    +            supports_standalone_function_call_output: true,
                 remote_compaction: RemoteCompactionSupport::V2,
             }
         }
  8. nscottnichols commented on Nov 27, 2026

    @nscottnichols

    Confirmed on stock Codex CLI 0.172.0.

    The standalone cross-thread delivery path still produces a named function_call_output without a call_id:

    {
      "type": "function_call_output",
      "name": "send_message_to_thread",
      "namespace": "codex_tui",
      "output": "<codex_delegation>…</codex_delegation>"
    }

    When this item is included in a request to a strict Responses provider, the request is rejected with HTTP 400.

    These deliveries are new inputs to the receiving thread, not results of a tool invoked by that thread. Adding an arbitrary call_id therefore does not create a valid tool-result relationship. For affected providers, these standalone outputs should be normalized into external user messages during request assembly, while genuine tool calls and their paired outputs remain unchanged.

    A tested request-copy implementation of this normalization is included in the reference patch.

  9. Blitzball996 commented on Nov 28, 2026

    @Blitzball996

    I confirmed a compaction and resume case on Windows with stock Codex CLI 0.172.0 and a Responses-compatible HTTP endpoint.

    • Before compaction, the receiving thread already had four standalone function_call_output items named codex_tui.send_message_to_thread. All four contained <codex_delegation> text and omitted call_id.
    • The persisted compacted.payload.replacement_history had 17 entries, including the same four output bodies and zero function_call entries. The failure therefore does not require compaction to strip an ID from a previously valid tool result.
    • Two consecutive turns failed with function_call_output requires call_id on HTTP requests; continuation via previous_response_id is only supported on Responses WebSocket v2. Sending a normal user follow-up did not clear the affected checkpoint.
    • For an isolated recovery check, I backed up the rollout and removed just the four obsolete notifications and their four aligned replacement_history_metadata entries from that checkpoint. Earlier events stayed in the rollout. After reloading the same thread ID, I submitted plain user input. The client reported fallback from WebSockets to HTTPS, returned an assistant message and successfully ran a shell tool. No provider or model change was needed for this check.

    A regression test for the proposed request-time normalization could cover a cold resume from a compacted checkpoint with one standalone cross-thread notification and a genuine paired call/output. Assert that a strict HTTP endpoint accepts the resumed input, that the model still receives the notification content with its untrusted provenance, and that the real call's ID is preserved. We could not inspect intermediary traffic during the original failures; the observations above are from the client rollout and the recovery run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugcustom-modelsessionsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions