Repository navigation
[PR] fix: recognize tool_search pairs and drop orphan tool outputs at the Responses wire boundary - #5675
[PR] fix: recognize tool_search pairs and drop orphan tool outputs at the Responses wire boundary#5675ranxianglei wants to merge 2 commits into
Conversation
e224118 to
dbfb31c
Compare
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10994-pr.5675.170656cThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5675.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 检索了 open+closed 的 issue 与 PR(tool_search / orphan tool output / Responses wire boundary)均无同类修复;master 上此前既无 结论先行方向正确、修法到位,可合。审核中我修掉了一个它自己带进来的隐患(wire 规则编号撞车),已作为独立小提交推回分支;本地定向测试与 typecheck 全绿,远端 CI 在跑(暂无失败)。 结构化八问
审核中我做的手动改动(已在分支上,独立标注提交)
CI(读镜像缓存)当前 head 顺带发现(不阻塞本 PR,未另开 issue)wire 约束账本里早已存在与本 PR 无关的重复编号: 行为变更披露(确认 PR 描述已如实列明)
收工判定:可合。 逻辑正确、回归已审、缓存不受影响、无新配置;CI 分片跑完转绿即可由你合并(合并权在你)。 |
|
(ai: vllm-qwen/qwen3.8-27b) APPROVE — reviewed head 八问
测试有效性: 已顺手修:PR 正文漏描述了 I1 方向(commit CI:镜像快照时部分 test 分片仍在跑(0 failed),全量绿以远端 CI 为准。 判定:可合。 说明:GitHub 的正式 review 接口禁止对「自己账号提交的 PR」投 APPROVE(本 PR 作者与审核 token 同为 ranxianglei),故审核结论以本评论形式给出,供人工合并时参考。 |
(ai: vllm-qwen/qwen3.8-27b) 审核已完成,结论见上一条(APPROVE / 可合),PR 正文已顺手补齐(I1 方向 + WC-024/WC-025 + 用例计数)。合并为人工动作,我这边无待办。 |
(ai: vllm-qwen/qwen3.8-27b) CI 车道收工:冲突已解、红 shard 已修,最终 head 全绿,等人工 review/merge。 本次做了什么① 冲突解决(第一轮):分支基于旧 master(5594c13,rebase 前落后 #5629/#5491 合入)。rebase 到 master 后唯一冲突在 ② 三个红 shard 诊断(第二轮): ③ 修复(commit 75f2db4,test-only):把 ④ 并行披露:修复期间作者连推三笔(WC-023→WC-024 重编号 b10ab60、孤儿 call 补合成 lost-output 结果 c12aca9、tool_search_output 对齐真实 Codex 流量 93fe27c),我的修复 commit 都在其中,未冲突。 八问
判定:head 93fe27c 上 30 项 check 全部完成(14 success + 16 按设计 skip 的门控 e2e 车道,0 failed),mergeable=true 无冲突;mergeable_state=blocked 是 branch protection 等人工审批——可进入人工 review/merge。 |
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
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.
93fe27c to
d61520e
Compare
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-review of rebased head The branch was rebased onto current master (
已顺手修:PR body 仍引用 rebase 前的 ledger 号(WC-024/WC-025)和过时的 "WC-023 taken by #5432" 说明 → 已改为 WC-026/WC-027 + "WC-023/024/025 taken by #5432/#5998/#6636"(PR body 元数据 PATCH,HTTP 200,非分支 commit,无 commit hash)。 Two observations, neither blocks this PR:
8问
判定:APPROVE / 可合(代码层面)。合并仍由人工执行;合并前请确认 rebase 后 |
Closes #5670
What
Codex 0.166 emits
tool_search_call/tool_search_outputitem pairs (OpenAI tool-search feature) thatsrc/tool-pair-order.tsdid not know, so neither wire-boundary guarantee applied to them. A compression round that dropped a call while keeping its output then produced an unshippable request: strict backends (DeepSeek via Magpie) answer 400No tool call found for tool output <id>on every later turn, and the session is stuck on that model until restart. The mirror damage is equally fatal: a round that drops the output while keeping its call yields 400No tool output found for tool call <id>(#766's string) — no reordering saves it either, so an abandoned mid-history call is completed with an honest synthesized lost-output result instead of being shipped broken.Changes
tool_search_call/tool_search_outputadded toCALL_TYPES/OUTPUT_TYPES; the [BUG] No tool output found for tool call call_xxxx #766 hoist guarantee now covers the family.dropOrphanToolOutputs(), integrated as the first stage ofhoistTrappedToolItems: an output whosecall_idmatches no call in the outbound array is dropped and logged (warn). All four call sites (prepare-responses.ts:417/:787,compress-loop-responses.ts:215,adapter-responses.ts:337) inherit it with zero changes. Outputs with a missing/emptycall_idare kept (unjudgeable — dropping would lose data we cannot prove orphaned).completeOrphanToolCalls(), the second stage: a call BEFORE the trailing run whosecall_idmatches no surviving output was abandoned mid-history by compression; its pairing is completed with a family-matched synthesized lost-output result inserted right after the call (function_call_output/custom_tool_call_outputcarry "tool output lost during context compression"; an orphantool_search_callgets a minimal emptytool_search_output). In-flight calls in the trailing{call, reasoning}suffix are exempt; no-op (same array reference) when every call has a surviving output.hoistTrappedToolItemsimport removed fromsrc/server.ts:104.Behavior changes (old -> new)
warnlogNo tool output found for tool call <id>(#766's string), turn unrecoverablewarnlogcallA, callB, outA, outBTests
tests/tool-pair-order.test.ts: +16 cases (pair registration, orphan drop across families, orphan-call completion / I1 direction, negatives: orphan CALLS kept / missing-call_id kept / same-reference byte-stability / interleaving left alone);assertNoTrapextended to the tool_search family.