Repository navigation
[PR] fix(responses-wire): tool_search pair guard + hosted web_search_call run integrity (#5670, #7296) - #7372
ranxianglei wants to merge 3 commits into
Conversation
Rebase the #5670 branch onto master (6453fee, v0.1.216) and re-land the full fix as one coherent change: - src/tool-pair-order.ts: register tool_search_call/tool_search_output in the pair sets; dropOrphanToolOutputs drops outputs whose call_id matches no call in the array; completeOrphanToolCalls synthesizes an honest lost-output result for mid-history calls whose output was dropped (trailing-run exemption keeps in-flight batches untouched); both run inside hoistTrappedToolItems, so all four wire-boundary call sites are covered without call-site changes. - tests/tool-pair-order.test.ts: 26 cases covering both directions, trailing-run negatives, family shapes (tool_search synth carries status:"completed" per real Codex traffic), and same-reference identity on healthy input. - tests/wire-contract-fakes.ts / tests/wire-contract.test.ts: ledger entries + validator clauses + probes for both directions. The rules landed as WC-023/WC-024 on the feature branch; master's #5432, #5998 and #6636 took WC-023/WC-024/WC-025 first, so they renumber to WC-026 (orphan output) / WC-027 (orphan call) on this rebase. - src/server.ts: drop the unused hoistTrappedToolItems import. - tests/responses-tool-images.test.ts: rebuild the adapter assertion on a well-formed tool pair (master's c31fd99 overlap-sweep rewrite of hoistTrappedToolItems is kept; the two new stages run before it on pair-clean input). Supersedes the pre-rebase commits (7772d05, e224118, c12aca9, 93fe27c) which are no longer ancestors of this branch. Closes #5670 (cherry picked from commit 742d992)
2026-11-19, Codex Desktop behind a Responses gateway (provider unstated): HTTP 400 'No tool call found for tool search output with call_id <redacted>' — the same constraint with the item type name interpolated into the message. Corroborates the shape; the historical 400 was not captured at its exact failing boundary, so this does not verify this branch or locate the historical loss. (cherry picked from commit d61520e)
) responsesToCore flattens hosted calls (web_search_call, file_search_call, mcp_call, ...) into contentType:"reasoning" cores. The Responses ordering repair classified them as a second reasoning item and inserted a user separator between the real reasoning and the hosted call, splitting the assistant run — the server then rejects the web_search_call "without its required 'reasoning' item". Classify a flattened hosted-call core (whose rawResponsesItem sidecar carries a hosted-call wire type) as tool-call (phase 2) so the reasoning -> hosted call run stays intact. The separator still lands between distinct runs. Closes #7296 (cherry picked from commit 2a2a9e9)
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Reviewed PR #7372 (root-cause aggregation for the responses-tool-ordering batch, aggregation #7354). Overlap/duplicate screening. This PR cherry-picks (with Verification (local, targeted).
Code review findings.
结构化八问
判定: 代码审核正面——修在正确的层(wire 边界/分类逻辑,非 payload 掩码)、无回归、测试有牙、diff 干净。等 CI 绿给全量回归判定;合并顺序(#7372 vs #7322 的 #7296 重叠)请 owner 拍板。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI status update: still fully queued after ~15 min (24 queued, 0 in_progress, 0 failed) — no runners are picking up the test shards yet. This is a fleet runner-availability issue, not a code issue; the PR head is unchanged. My code-review verdict (positive, see prior comment) stands; the full-regression verdict is blocked on CI landing. I'll keep monitoring and report the moment the |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI landed — full regression green: 30/30 checks complete, 14 success + 16 skipped, 0 failed. All Final verdict: mergeable (code + CI). Recap of the review:
Remaining owner decision (not a code issue): merge sequencing — #7372 and #7322 both carry the #7296 commit; whichever merges first makes the other's #7296 hunks no-ops, and #5675/#7302 go empty once #7372 lands. I can't merge PRs (human-only) — please sequence and merge when ready. |
Root-cause fix for the responses-tool-ordering batch (aggregation #7354): the two Responses-wire ordering defects in the same failure domain — the wire-boundary tool-pair integrity pass not knowing a tool-item family, and the assistant-run repair misclassifying flattened hosted calls — fixed in one PR per the root-cause aggregation contract.
Both fixes are cherry-picked with
-xfrom the member PRs (authorship preserved):#5670 — tool_search_call / tool_search_output unknown to the tool-pair pass → upstream 400
Cherry-picked from #5675 (commits 742d992, d61520e).
Codex 0.166 emits
tool_search_call/tool_search_outputpairs thatsrc/tool-pair-order.tsdid not know, so the #766 hoist guarantee never applied to them; a compression round that dropped a call while keeping its output produced an unshippable request that strict backends (DeepSeek) reject withNo tool call found for tool output <id>on every later turn, and the session is stuck on that model until restart.tool_search_call/tool_search_outputadded toCALL_TYPES/OUTPUT_TYPES(src/tool-pair-order.ts:30-31).dropOrphanToolOutputs) — an output whosecall_idmatches no call in the outbound array is dropped and logged; an output with a missing/emptycall_idis kept (unjudgeable — dropping would lose data we cannot prove orphaned).completeOrphanToolCalls) — the mirror direction: a call before the trailing run whose output was dropped was abandoned mid-history by compression; its pairing is completed with an honest family-matched synthesized result (function_call_output/custom_tool_call_outputwithtool output lost during context compression, ortool_search_output {status: "completed", tools: [], execution: "client"}— field set matches real Codex traffic, upstream-verified in the tool_search_call / tool_search_output missing from tool-pair ordering -> upstream 400 "No tool call found for tool output" (Codex 0.166 + DeepSeek) #5670 thread), so the model sees the loss instead of re-issuing the call blind. The trailing run (calls + post-call reasoning only) is exempt: it is where an in-flight batch legitimately sits.All three guarantees are no-ops (same array reference, byte-stable) on healthy input; all four wire call sites (
src/server/prepare-responses.ts:466/:855,src/compress-loop-responses.ts:219,src/loop/adapter-responses.ts:332) inherit them with zero changes.#7296 — ordering repair split a reasoning item from its hosted web_search_call
Cherry-picked from #7302 (commit 2a2a9e9).
responsesToCore(kernel) flattens every hosted-call item —web_search_call,file_search_call,mcp_call,computer_call/_output,image_generation_call,code_interpreter_call— into a core withcontentType: "reasoning"(the raw item rides therawResponsesItemsidecar).repairResponsesAssistantOrdering(src/server/responses-ordering.ts) classified that core as a second reasoning and its run-boundary rule then inserted a synthetic user separator between the realreasoningand theweb_search_call; the Responses server rejects aweb_search_callseparated from itsreasoningitem ("provided without its required 'reasoning' item"). Fix: acontentType: "reasoning"core whose sidecar carries a hosted-call wire type is now classified as tool-call (phase 2), keepingreasoning → hosted callin one run; only the sidecar's wiretypedecides — never the core text or id, which the codec re-derives and a client could shape. Separators still land only between distinct runs.Behavior changes (old → new)
user → reasoning → web_search_callafter a hosted searchModel-facing text (new, recovery-only)
The synthesized lost-output result text
tool output lost during context compression(and the emptytool_search_outputshape) is new text the model can read — but only in requests that were previously rejected wholesale (400), i.e. a state with no prior model-visible behavior. No existing model-facing string was changed.Overlap note (for merge sequencing)
Verification
user → reasoning → web_search_callnow renders with 0 separators (was 1).Fixes #5670
Fixes #7296