codex - ✅(Solved) Fix Consistently error "No tool call found for function call output with call_id" [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17630Fetched 2026-04-14 05:42:03
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2referenced ×2cross-referenced ×1

Error Message

{"type":"error","status":400,"error":{ I just send a simple task request, so no error is expected.

Fix Action

Fixed

PR fix notes

PR #1: fix: repair orphan function_call_output to prevent Responses API 400

Description (problem / solution / changelog)

Summary

Fixes openai/codex#17630 — the recurring 400 invalid_request_error: "No tool call found for function call output with call_id …" from the Responses API. This is the mirror image of openai/codex#16255 (call without matching output) and the same class as openai/codex#17161 (orphan reasoning).

Two underlying bugs combine to produce the error:

  1. Cleanup-skipped early returns in try_run_sampling_request. Two ?-style early returns (stream-item decode error, handle_output_item_done error) bypass the shared trailer that calls drain_in_flight. Any in-flight tool future drops its FunctionCallOutput / CustomToolCallOutput, leaving the call recorded with no output.
  2. Stale retry prompt in run_sampling_request. build_prompt(...) runs once before the retry loop, so retries reuse a frozen Prompt.input even after history has been amended by drain.

Together with CodexErr::InvalidRequest being non-retryable, the turn fails hard with no localized self-heal.

Changes

  • codex-rs/core/src/codex.rs
    • try_run_sampling_request: convert mid-loop ? returns to break Err(err) so the trailer always reaches drain_in_flight.
    • run_sampling_request: rebuild the prompt from clone_history().for_prompt(...) inside the retry loop so each attempt picks up newly-drained items.
    • Add classify_replay_repair() for "No tool call found for function call output with call_id …" and "Item … of type reasoning was provided without its required following item.". On match, repair in-memory history once and retry — short-circuits before the existing non-retryable check.
  • codex-rs/core/src/context_manager/normalize.rs: drop_function_call_output_by_id covering both FunctionCallOutput and CustomToolCallOutput.
  • codex-rs/core/src/context_manager/history.rs + state/session.rs: expose the helper on ContextManager / session, bumping history_version so the websocket incremental-delta baseline (client.rs:get_incremental_items) is invalidated after repair.
  • Tests: new tests/suite/orphan_function_call_output.rs (registered in mod.rs); extended tests/suite/stream_no_completed.rs with the function-call/output early-close case; expanded context_manager/history_tests.rs.

Notes / scope

  • One-shot repair per run_sampling_request (capped to avoid loops); falls through to the original error if the server keeps rejecting.
  • No protocol error enum changes — InvalidRequest stays non-retryable; the repair path intercepts before the retryability check.
  • Out of scope: commentary-only retry accounting (openai/codex#16255 point 3) and partial-response WebSocket resume (openai/codex#13949).

Test plan

  • cargo fmt
  • cargo clippy -p codex-core -- -D warnings
  • cargo test -p codex-core stream_no_completed -- --nocapture
  • cargo test -p codex-core orphan_function_call_output -- --nocapture
  • cargo test -p codex-core client_websockets -- --nocapture
  • cargo test -p codex-core context_manager::history_tests -- --nocapture
  • Manual repro: mock Responses endpoint that returns the exact invalid_request_error body from openai/codex#17630; verify Codex repairs and the turn ultimately succeeds.

🤖 Generated with Claude Code

Changed files

  • codex-rs/core/src/codex.rs (modified, +99/-0)
  • codex-rs/core/src/context_manager/history.rs (modified, +20/-0)
  • codex-rs/core/src/context_manager/history_tests.rs (modified, +455/-0)
  • codex-rs/core/src/context_manager/normalize.rs (modified, +29/-0)
  • codex-rs/core/src/state/session.rs (modified, +8/-0)
  • codex-rs/core/tests/suite/mod.rs (modified, +1/-0)
  • codex-rs/core/tests/suite/orphan_function_call_output.rs (added, +410/-0)
  • codex-rs/core/tests/suite/stream_no_completed.rs (modified, +125/-0)

Code Example

{"type":"error","status":400,"error":{
    "message": "No tool call found for function call output with call_id call_Sp2iWQ8IWnaN7pmtKRxmn2ky.",
    "type": "invalid_request_error",
    "param": "input",
    "code": null
  }}
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.120.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.3-codex

What platform is your computer?

Darwin 25.4.0 arm64 arm

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

VSCode

What issue are you seeing?

{"type":"error","status":400,"error":{
    "message": "No tool call found for function call output with call_id call_Sp2iWQ8IWnaN7pmtKRxmn2ky.",
    "type": "invalid_request_error",
    "param": "input",
    "code": null
  }}

What steps can reproduce the bug?

Uploaded thread: 019d8665-5784-7022-9945-c5da8210ab09

What is the expected behavior?

I just send a simple task request, so no error is expected.

Additional information

No response

extent analysis

TL;DR

The error message suggests a potential issue with the function call output, and verifying the input parameters and the call_id might help resolve the "No tool call found" error.

Guidance

  • Check the call_id parameter in the function call to ensure it matches the expected format and is correctly generated.
  • Verify that the input parameters for the function call are valid and correctly formatted, as indicated by the param: "input" error.
  • Review the uploaded thread 019d8665-5784-7022-9945-c5da8210ab09 for any additional context or clues about the error.
  • Consider testing the function call with a minimal, simplified input to isolate the issue.

Notes

The error message specifically mentions an "invalid_request_error" with a "param" of "input", which suggests that the issue might be related to the input parameters or the function call itself. However, without more information about the function call or the input parameters, it's difficult to provide a more specific solution.

Recommendation

Apply workaround: Given the limited information, it's recommended to try verifying and adjusting the input parameters and the call_id to see if that resolves the issue, rather than upgrading or making significant changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING