sub2api icon indicating copy to clipboard operation
sub2api copied to clipboard

bug: Codex CLI edit/resend can break WS tool continuation with 'No tool output found for function call'

Open KnowSky404 opened this issue 7 months ago • 0 comments

Summary

On v0.1.119, Codex CLI WebSocket sessions can enter a broken reconnect loop after leaving the terminal view and resending from edit mode.

Observed client flow:

  1. Send a message in Codex CLI against a sub2api OAuth /responses endpoint.
  2. Press Esc to leave the terminal view.
  3. Press Esc twice to enter edit mode.
  4. Resend the edited prompt.
  5. The request fails with:
    • No tool output found for function call call_*
    • then repeated Reconnecting...

This is distinct from image-history-only failures and from rs_* reasoning replay failures. It appears to be another multi-turn tool continuation bug specific to Codex CLI edit/resend behavior.

Production Evidence

From production logs on 2026-04-29 17:02:48 +0800:

ingress_ws_function_call_output_prev_infer account_id=91 turn=2 conn_id=oa_ws_91_591 action=set_previous_response_id previous_response_id=resp_008b9ba1f288d4bd0169f1c92fad7881919a7284dc9c4097e5

Immediately followed by:

ingress_ws_error_event account_id=91 turn=2 conn_id=oa_ws_91_591 idx=2 fallback_reason=event_err err_code=- err_type=invalid_request_err err_message=No tool output found for function call call_FMarYwXbOva7sdmdklTybxZ9. previous_response_id=resp_008b9ba1f288d4bd0169f1c92fad7881919a7284dc9c4097e5 previous_response_id_kind=response_id response_id=- store_disabled=true has_prompt_cache_key=true

The gateway inferred a continuation turn with function_call_output and auto-filled previous_response_id, but upstream still rejected the request because the expected tool output for the referenced function call was not present in a way upstream accepted.

Why this looks different from existing issues

Related but not identical:

  • #1915 reports No tool output found for tool search call after image generation / image modification in the same session.
  • #2067 reports rs_* reasoning replay causing turn-2 failures when clients replay prior assistant items under store=false.

This issue reproduces without image generation and is triggered specifically by Codex CLI edit/resend flow after leaving the session with Esc.

Suspected Root Cause

The WS ingress continuation logic currently treats the resend as a valid function_call_output continuation and preserves / infers previous_response_id, but it does not fully validate that the resent payload still carries a tool-output chain consistent with the referenced prior function call.

So the gateway forwards a continuation turn that is structurally close enough to continue, but semantically incomplete for upstream, which returns:

No tool output found for function call call_*

Reproduction

Environment:

  • sub2api v0.1.119
  • OpenAI OAuth account
  • /responses WebSocket path via Codex CLI

Steps:

  1. Start a new Codex CLI session through sub2api.
  2. Send a prompt that causes at least one tool/function call in the conversation.
  3. Press Esc to leave the active terminal/stream view.
  4. Press Esc twice to enter edit mode.
  5. Edit the previous content and send again.
  6. Observe the client error No tool output found for function call call_* and then repeated reconnect attempts.

Suggested Direction

  • Harden the WS continuation path for edit/resend turns.
  • Before preserving or inferring previous_response_id for a resend containing function_call_output, verify that the resent payload still contains a valid tool-output continuation chain for the referenced upstream function call.
  • If the tool-output chain is incomplete or no longer trustworthy, degrade safely instead of forwarding a broken continuation turn that poisons the session.

KnowSky404 avatar Apr 29 '26 09:04 KnowSky404