Skip to content

Goal mode sends function_call_output input item without required call_id, breaking custom Responses API providers #62665

Closed as not planned

Description

@kuang22

What version of Codex CLI is running?

Codex CLI 0.169.0 / 0.170.0

What subscription do you have?

Pro

Which model were you using?

custom

What platform is your computer?

Darwin 27.0.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

Kitty

Codex doctor report

What issue are you seeing?

• Goal active Objective: This is a test
■ stream disconnected before completion: stream closed before response.completed

What steps can reproduce the bug?

  1. Configure a custom provider with wire_api = "responses":
model_provider = "dashscope"

[model_providers.dashscope]
name = "dashscope"
base_url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
wire_api = "responses"
env_key = "DASHSCOPE_API_KEY"
  1. Start codex with this provider, set a goal (any objective, e.g. /goal 这是一个短goal测试).
  2. The goal continuation turn starts automatically. Every sampling request fails immediately; after 5 retries codex shows:
stream disconnected before completion: stream closed before response.completed

Goal becomes "stalled". Without a goal, the same session/model/endpoint works fine.

Root cause

When a goal is active, codex injects the goal objective into the request input as a custom item:

{
  "type": "function_call_output",
  "id": "fco_01a1f6d0-b42b-7051-ace5-1a3ae4be459a",
  "name": "goal_objective",
  "namespace": "agent",
  "output": "这是一个短goal测试"
}

Per the Responses API schema, function_call_output requires a call_id referencing a preceding function_call. This item has none (and there is no matching function_call in the input). Providers that validate the schema reject the request.

The injection is unconditional with goal mode: it happens for short and long objectives alike, regardless of content. Short objectives are additionally inlined in the user_goal context message; long ones are redacted from the rollout, but the malformed item is always sent.

This is a regression: goals completed successfully on 2026-11-17 with the previous binary; the 0.169.0 binary was installed on 2026-11-18; all goal sessions fail from 2026-11-19 onward.

Observed provider error

DashScope returns HTTP 200 with an SSE error event (also see secondary issue below):

event:error
:HTTP_STATUS/400
data:{"code":"InvalidParameter","message":"Invalid 'call_id': call_id is required for function_call_output.","request_id":"0a6f00a1-cbe4-9d27-928a-cea5d65b1c77"}

Minimal reproduction (no codex needed)

POST to /v1/responses on any strictly validating provider:

{
  "model": "glm-5.3-prime",
  "stream": true,
  "input": [
    {"type": "function_call_output", "name": "goal_objective", "namespace": "agent", "output": "这是一个短goal测试"}
  ]
}

Result: InvalidParameter: call_id is required for function_call_output.

Control: the same text as a regular user message completes normally. Deleting only the function_call_output item from a captured 335KB real codex goal request and replaying it unchanged also completes normally — this isolates the single offending item.

Secondary issue: SSE event:error not surfaced

Codex does not parse the provider's in-stream error event (event: error with :HTTP_STATUS/400), so a protocol-level rejection is reported as a connectivity problem:

stream disconnected before completion: stream closed before response.completed

This misleads users toward network/moderation/upstream-outage hypotheses (our investigation spent several wrong turns on exactly those). Surfacing the in-stream error payload would make the real cause visible immediately.

What is the expected behavior?

  • Goal-mode requests should only contain schema-valid input items (e.g. inject the objective as a message, or a well-formed tool-call pair).
  • In-stream event: error payloads should be surfaced to the user instead of being reported as a stream disconnect.

Additional information

No response

Activity

  1. added
    bug
    on Nov 20, 2026
  2. added
    CLI
    custom-model
    tool-calls
    connectivity
    on Nov 20, 2026
  3. github-actions commented on Nov 20, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. r266-tech commented on Nov 20, 2026

    @r266-tech

    I reproduced the request shape on the published Codex CLI 0.171.0 Linux arm64 binary. I ran codex app-server against a scripted loopback Responses endpoint in a container with networking disabled. The fixture accepts a tool output when its call_id matches an input function call and returns HTTP 400 for an unmatched output.

    Case Captured request Turn result
    Ordinary text turn No function output Completed
    Scripted dynamic tool Both the call and its output carried call_fixture_echo Completed
    Goal continuation, 24-character objective goal_objective output with namespace: "agent" and no call_id or matching call HTTP 400, failed
    Goal continuation, 2,199-character objective Same goal_objective shape HTTP 400, failed

    For each Goal case I completed an ordinary turn on a fresh thread, then set the objective with thread/goal/set and status: "active". The release source adds the objective as AdditionalContextKind::Untrusted when it constructs the continuation. Goal continuation in 0.171.0

    With the fixture's HTTP 400 response, turn/completed reported failed and included the fixture error text. The streamed error path is tracked in #61547.

    AI-assisted fixture and analysis.

  5. etraut-openai commented on Nov 21, 2026

    @etraut-openai
    Contributor

    (response from codex)

    Thanks for investigating this. The current Responses API reference lists call_id as optional for function_call_output. Codex intentionally uses a named output for goal context, but DashScope appears to require call_id.

    You can switch Codex to send that context as a message by adding this to config.toml:

    [features]
    untrusted_as_tool_output = false
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

    CLIbugconnectivitycustom-modeltool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions