Repository navigation
fix(loop): unify Responses JSON loop trigger extraction & proxy dispatch (#1439) - #1448
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1448Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1448.tgz
npm install -g packageInstall instructions are refreshed on each push. |
f431db9 to
9a66f03
Compare
[bot] 🏷 Review of PR #1448 (fixes #1439) — verdict: mergeable once the remaining CI checks go green ① Original-issue direction. #1439 is real and the fix hits the root cause. Evidence: I ran the new behavioral tests against an ② Regression audit (pre-existing behaviors on touched paths):
③ Code. Clean. One precision note: the PR body's "absorb/rules(image_full) … old ④ Test validity. The 3 new tests have teeth — A/B verified: fail on master (no marker, trigger not executed), pass on the branch (📊/🔍 marker present, ⑤ Diff cleanliness. 12 files, every line serves the dedup; the two one-line test import repoints are necessary fallout; no whitespace churn, no unrelated files. Behavior change (intentional, disclosed): non-streaming Responses text protocol only — Rebase: the PR was 11 releases behind master (base 中文摘要:把 Responses 非流式 JSON 压缩循环里与统一循环漂移的私有实现(文本触发器识别 + 代理工具分发)收敛为单一来源,修掉 Codex 文本模式下 acp_status/search_context/decompress 等只读工具标签被静默丢弃、从不执行的缺陷;回归测试已验证在 master 上失败、修复后通过,已 rebase 到最新 master(force-push 特性分支,未动 master),CI 的 e2e codex 通道已通过——剩余 CI 检查转绿后即可合并。 |
[bot] 🏷 CI 全绿确认 — rebased head Review 结论维持上一条不变:修复打到了根因(删除漂移的私有副本而非掩盖症状),既有行为逐项审计无回归,行为变更(非流式文本协议的三个只读触发器从静默丢弃变为执行+标记+剥离标签)已按旧值→新值披露,回归测试有牙(master 上失败/分支上通过已 A/B 验证)。 合并操作留给人类:#1448 中文摘要:CI 13/13 全绿,PR #1448 可合并——合并动作按规范由人工执行。 |
…triggers, canonical proxy dispatch, buildVisibilityMarker moved to core (#1439)
…ster (#1439 review) Rebase conflict resolution: master's #1419 threaded a 5th ctx arg into executeSearchContextTarget inside the local dispatch this PR deletes — kept the deletion (the shared src/loop/core.ts dispatch already carries the new arg on master). New pin: a no-trigger response returns the SAME object reference — the JSON loop only re-serializes when a trigger fires.
Deep review (rebased onto master → a13c275) — ✅ approveWhat it does (verified): one shared Single-run semantics confirmed: pure mutating rounds consume each call exactly once; terminal mixed exits execute the leftover compress once in the downstream fallback rewriter; Byte fidelity: no-trigger response returns the same object reference — now pinned by a new test (unknown top-level keys survive untouched; the loop only re-serializes when a trigger fires). Pre-existing caveat (NOT this PR): the server's non-streaming branch always round-trips the response through parse/stringify even with no trigger — response-side only, semantically identical. Rebase done (a13c275): base was 12 behind; master's #1419 threaded a 5th ctx arg into Follow-up filed (pre-existing asymmetry, unchanged by this PR): in a MIXED response (text-trigger compress + real tool call), the JSON path silently drops the text-trigger compress (stripped, never executed, no marker) while the streaming loop executes it before the realCalls gate — residual JSON↔SSE drift in the spirit of #1439, worth its own fix rather than bundling here. |
9a66f03 to
a13c275
Compare
[bot] 🏷 独立复核了你这份 deep review,全部属实 — 逐项验证结果:
补一条行为变更披露(PR body 未列,属统一化的连带效果):JSON 路径的 结论维持:可合并(mergeable/clean,CI 全绿)。合并操作留给人类:#1448 中文摘要:对 deep review 的全部论断做了独立复核(rebase 距离、#1419 五参冲突处理、identity 测试、CI 13/13、#1459 立项及两侧代码的 mixed-response 不对称)均属实,另补披露一条 search_context 获得 CCR v3 上下文的连带行为变更——PR 可合并,待人工执行。 |
Summary
Unifies the non-streaming Responses JSON loop (
src/compress-loop-responses.ts) with the unifiedsrc/loop/implementation, closing the semantic drift reported in #1439. The JSON path is the only surviving "keep originals as baseline" leftover from the unified-loop migration (the OpenAI/Anthropic legacy loops are already gone); it had drifted on two axes:adapter-responses.ts) recognizes 4 text triggers (compress/acp_status/search_context/decompress); the JSON loop recognized onlycompress. Same protocol, only thestreamflag differs, yet the other three triggers were dropped in non-streaming responses.executeProxyToolcopy missingabsorb,rules, andimage_full, and used the oldparseCompressInput(args)signature withoutcallId.Approach (Option B — surgical dedup)
Instead of routing the JSON path through the full
runCompressLoopgenerator (the issue's suggested Option A), I removed the duplicated logic so both paths share one source of truth:extractResponsesTextTriggers()insrc/compress-tool.ts; bothadapter-responses.ts(streaming) andcompress-loop-responses.ts(JSON) now call it. Any tool added later lands in both paths automatically.executeProxyTool; it now delegates to the canonicalexecuteProxyToolinloop/core.ts(now exported). Closes the absorb/rules/image_full gap and adopts thecallIdobservability param — no per-path drift going forward.buildVisibilityMarkermoved intoloop/core.ts; the misnamed 23-linesrc/compress-loop.ts(its last remaining export) is deleted and all importers repointed.Why not Option A: the JSON orchestrator's final wire shape (one JSON body) genuinely differs from the streaming SSE generator, and folding it into
runCompressLoopwould be a larger wire-shape refactor (§7.4 human-review territory) with higher risk for no behavioral gain. Option B removes the actual defect — unsynced private copies, the stated root cause — at low risk while keeping each transport's thin orchestration intact. Full file deletion can follow as a separate refactor if desired.Behavior changes (old → new)
Intentional changes to the non-streaming text-protocol path only (streaming path is byte-identical — it already used the shared extraction/dispatch):
acp_status/search_context/decompresstext triggers in non-streaming text responses<acp_status>… tag was left inoutput.textand leaked to the client (underscore-namespaced tags are deliberately not stripped by the echo filter)absorb/rules/image_fullproxy calls in the JSON path[Unknown proxy tool: …]executeProxyToolabsorb, so the model could previously be taught to call a tool the JSON path didn't understandparseCompressInputin the JSON path(args)(args, callId)Untouched: config schema, persistence format/version, message-ref/id logic,
src/update.ts, and the acp-kernel pin.Regression test
New
tests/fix-1439-responses-json-triggers.test.ts(3 tests) asserts the JSON path now (a) extracts all four text triggers identically to the shared extractor, and (b) executesacp_status/search_contexttext triggers without an upstream re-fetch, surfacing the expected marker while stripping the raw tag. Teeth verified: the test fails on clean master (pre-fix) and passes on this branch.Pre-flight (rebased head, base = master @088bb348)
npm run typecheck→ cleannpm run build→ successnpm test→ 2455 tests, 2449 pass, 2 skip, 4 fail — all 4 are pre-existing environmental failures that fail identically on clean master (live-ps host-pid walk, two claude hook-e2e cases, and the#393claude-opus-5-thinking window case); none touch this diff's code paths. My 3 new tests are within the passing set.Closes #1439