Repository navigation
Conversation
[bot] 🏷 查重: 不重复 — searched open+closed issues and PRs for matched-stop_sequence preservation: #5531 is a different bug (delta:null crash), #6021 is retry-decision logic, and the auto-mode-forge path forges its own stop_sequence independently (e2e-anthropic.test.ts:458-546) and is unaffected. No parallel fix PR exists for #7227. 标签: bug + p2 + claude-code + scope/wiring + review中 (applied to both PR #7228 and issue #7227) — 功能缺陷(元数据丢失,非崩溃/非缓存泄露 → p2),Anthropic wire 协议接线层,claude-code 车道。 ReviewThe fix is correct and minimal. The null was produced by Verified locally (worktree at PR head 36a8331 vs master a446a3c):
Regression audit (existing behaviors on the touched paths):
Behavior change (disclosed): loop-path terminal Both compression modes reasoned: proxy mode gets the fix; plugin mode passthrough is unaffected (upstream bytes verbatim). Code quality: clean — per-request closure var, one explanatory comment (why the reset exists), style matches the file, no new deps/API/config. Test quality: real loopback HTTP through the production server (port 0, deterministic) plus adapter-level isolation tests; assertions pin the exact client-visible terminal. CI status (live-checked):
Verdict: review passes — correct, minimal, well-tested, no regressions found. Pre-merge: (1) the e2e run (now triggered) must be green; (2) the 3 stuck shards need cancel + re-run. Wire-shape change → human-only merge per §7.4; I will not merge. 八问
行为变更披露:loop 路径终止帧 结论:审查通过;可合并条件 = e2e(ci:full 已触发,待跑)绿 + 3 个卡死 shard 重跑后 CI 全绿。wire 形状变更按 §7.4 属 human-only,合并由 owner 执行。 |
Fixes #7227
Problem
When an Anthropic streaming response ends on a custom stop string, the tool loop retains
stop_reason: "stop_sequence"but replaces the provider's matchedstop_sequencewithnull. Clients cannot identify which requested boundary ended the response. The no-tools passthrough already preserves the value.Change
Keep the matched string in the Anthropic adapter for the current upstream attempt and carry it into the synthesized terminal frame only when the final reason is
stop_sequence. Reset it for each round or retry. A usage-only delta leaves the observed match intact; an explicit null clears it. Preserve literal strings without trimming or inferring a match from the request.The existing early-stop mapping, natural completions and legacy error completions continue to report null. No generic adapter API, configuration or kernel change is needed.
Validation
acp_statuscontinuation followed by a matched stop, no-tools passthrough, and natural completion with unmatched configured stops. The first three fail on the original source; both controls pass.npm run typecheck,npm run build, the test import-graph gate, CI live-file classification andgit diff --checkpass. Rebuilt kernel and pi-subagents artifacts match the components used by the tests byte for byte.The real Codex four-phase model E2E has not run and remains a required pre-merge check. The zero-token preflight found the CLI and built artifact, but the local upstream at
127.0.0.1:8199was unreachable. The HTTP fixtures above use a local scripted provider; they are not a real-model E2E result.Novelty check
Compared all 276 live Afloat16 fork heads and 475 upstream history entries, covering 64 complete versions of this adapter. Each existing terminal constructor still emitted a literal null. Also inspected the actual patches for #5202, #5530, #2691 and #7207; those address other lifecycle behavior.