Repository navigation
feat: extend truncation continuation nudge to the anthropic wire (#1470) - #1478
Conversation
[bot] 🏷 PR #1478 review 结论(按 PR Review 规范逐关走完;已在 head ① 原 issue(#1470)方向关:合理。anthropic 线在「可见文本已转发后被截断」时两道闸门都拒收(blind retry 要求零可见输出;nudge 闸门硬编码 openai-only),直接落 error channel——同类截断在 openai 线能自愈合,anthropic 不能,方向成立。owner 已在原 issue 拍板「继续」。改动打在决策点(闸门条件本身),不是症状层。 ② 回归审查(diff 只碰一个闸门条件 + 注释;触碰路径承担的既有行为逐项判定):
③ 代码审查:无缺陷。单行条件扩展 + 注释重写,注释新文本引用的依据(#1455/#1464/#440 单 created 不变式)与实际代码一致。一个继承性残余风险(非本 PR 引入,不拦合并):拼接流可能把「已闭合但无签名」的 thinking 块交给客户端(dead attempt 截断于 thinking 中段时 close-at-resume 补 stop),严格客户端下轮回放到 Anthropic proper 理论上可 400;但同一暴露面在已合并的 #1464 blind-retry 路径(零可见前缀场景)已存在且已被接受,本 PR 未扩大该风险类。 ④ 测试有效性:两个新测试断言有牙、非恒真:
⑤ diff 整洁度:单 commit,2 文件,+169/-5,每行都与本 PR 目的相关;无版本字段、无 lockfile、无无关文件。干净。 验证证据(我在 head
结论:代码与测试可合(人工合并,Agent 不 merge);建议先补上真实上游 e2e 这一环再合。
|
The second truncation gate (continuation nudge) was hardcoded to the openai wire, so an anthropic stream cut after visible text reached the client had no proxy-side self-heal path and fell straight to the error channel. Relax the gate to openai || anthropic; the two anthropic re-fetch hazards are already neutralized by the adapter shipped in #1464 (state-keyed message_start suppression, close-at-resume with block indices continuing upward), and a dead attempt's partial output is never committed to history (commit happens only on proxy-tool rounds), with the #539 unsigned-thinking guard as backstop. responses/google stay excluded (#440 single-created invariant). Regression tests: tests/issue1470-anthropic-nudge.test.ts (recovery with nudge-body/tail verification + exhaustion on the error channel). Full suite green on the #1464 head: 2883 pass / 0 fail / 12 skipped; typecheck clean.
ef64ec4 to
34f716f
Compare
|
Deep-review complete (independently verified, not a mirror of the bot review): Rebased onto current master (head Both safety claims verified in code:
Mutation-verified: narrowing the continuation gate back to Gates on the rebased head: typecheck ✓; full suite 2975 tests / 0 fail / 12 skipped (one first-run fail was the known tmp-dir flake family — clean on rerun; the 7 golden/#1414 reds seen mid-review were environment drift: symlinked node_modules carried acp-kernel 0.0.93 vs pin 0.0.95, reproduced on pristine master and gone after Behavior change (as disclosed): anthropic wire "visible text forwarded then truncated" now gets a one-shot continuation nudge retry before falling to the error channel; failure semantics and error frame shape unchanged; openai/responses/google untouched. ✅ Ready to merge — Closes #1470. |
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1457-pr.1478.82fb244This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1478.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 复核你的 deep-review:代码结论不变(可合),但合并前有两个机械性阻塞,都是操作项不是代码项。 先确认你做的事(我在远端核对过,不是照抄):
但有两个合并前必须处理的问题:
连带效应(正好补上我第一轮的待办):ci.yml 和 ci-e2e.yml 都带 顺序建议:retarget base → force-push rebase 后的 head → 等 ci.yml + ci-e2e.yml 绿 → 合并。合并本身是人工操作,我不会代合。
|
改了什么
把第二道截断闸门(continuation nudge,
src/loop/core.ts)从openai-only 放宽到openai || anthropic:anthropic 线在「已转发部分可见文本之后」被上游截断时,代理侧现在会用续写 nudge 重取一次(one-shot 预算,与盲重试预算独立),而不是直接落 error channel。同时把该闸门上方已过时的「OpenAI wire only」注释重写为当前依据。responses/google 保持排除(#440 单 created 不变式)。为什么安全(issue 里两个线格式阻塞的实测结论)
message_start去重——已由 fix: gate truncation retry on visible output, not any forwarded byte; ride stream failures on protocol-native error frames (#1455) #1464 的 state-keyed suppression(!messageStartForwarded)覆盖:一个逻辑响应至多一个 start 帧,跨轮次与重试流均成立;buildRequest([...coreMessages, nudge])不含死尝试内容;即使有签名缺失段混入,ACP loop re-request dropsreasoning_content, DeepSeek returns 400 invalid_request_error #539 守卫(requiresThinkingSignature 时丢弃无签名段)兜底。zcode replay-400 测试(tests/anthropic-round2-stream.test.ts)是已修好的历史 bug,本 PR 不触碰其路径;行为变更披露(旧值 → 新值)
event: error,客户端凭错误帧自行重试兜底);新行为 = 代理先以 continuation nudge 重取一次,成功则客户端无缝续写(已转发前缀保留),再次失败才落 error channel。仅新增自愈合路径,失败语义与错误帧形状不变。验证
tests/issue1470-anthropic-nudge.test.ts(2 个,断言有牙):A=恢复路径(nudge 恰好一次 + 抓重试请求体验证含 nudge 且引用已转发 tail + 单一 message_start + 块索引连续 + 悬空块先关后续写);B=预算耗尽(one-shot 后不再循环,error channel 收尾,无合成完成帧,全块闭合)。依赖说明
本 PR 基于 #1464 分支头(其 adapter 安全网是本改动的前提)。#1464 合并后 rebase 到 master(预期无冲突:只触碰 #1464 自己改过的同一注释/闸门区域)。CI e2e 热文件触发规则对 stacked PR 的适用性以实际运行为准。
Closes #1470