You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fake-completion corrective retry derives from the raw client body, bypassing wire transforms the main attempt carried #1900
resolveFakeCompletion() (src/server.ts, ~L6454) builds its corrective-hint retry from opts.body, and BOTH call sites pass forward()'s raw client body parameter:
proxy streaming lane (~L6088): body — the untransformed client request;
plugin lane (~L5982): body — the agent's own body.
The MAIN attempt of the same request went out as wireBody — post wireTransform (learned compat-role rewrite #552/#583, steering, chain-stamp). The hinted retry therefore re-sends PRE-rewrite bytes even though the provider rejected those exact bytes earlier in the same request.
A turn streams a fake completion (tool-call XML without a tool block).
resolveFakeCompletion retries with injectFakeCompletionHint(protocol, rawBody) — the raw body still contains developer → upstream returns the same 400 → "fake-completion retry rejected … presenting original" → the user is shown the FAKE completion instead of a corrected turn.
Impact
Functional, narrow: requires the opt-in env var AND mid-session learned compat roles AND a real fake completion on the same turn. No data corruption — the failed retry falls back to presenting the original stream unchanged. Distinct mechanism from #1894 (that one is forensic pairing only, diagnostic); this one changes what bytes reach the provider, so it is a separate failure domain.
Suggested fix
Pass the effective wire bytes (wireBody, already in scope at both call sites) instead of the raw body, so the hinted retry derives from the same base the provider just accepted — then verify injectFakeCompletionHint handles the transformed shape per protocol. Decide the plugin-lane semantics explicitly (the agent owning its own re-issue body may be intentional there — document or align). Wire-behavior change: review-gated, not auto-merge territory.
Additional facet found while verifying (same mechanism, same failure domain):wireBody itself goes stale when the main attempt succeeded via a same-request re-send — the billion-context: 400 Bad Request when codex sends role: "developer" messages — request a request-body compat transform hook #552 role hop ships fixed.body (L5771) and the 使用pi 压缩后就提示prompt is too long #1195 overflow refold ships refolded (L5906); neither updates wireBody. So passing wireBody alone would still fail on the very turn where the role was learned in-request (first request of the session: 400 → hop → fake completion on that same turn → retry still carries developer). The fix covers both: wireBody now tracks the last successfully sent body, and both call sites pass it.
Plugin-lane semantics decision: align with the proxy lane (documented in code) — the plugin forward goes through the same single dispatch carrying wireBody, so the retry must derive from that same accepted base; the agent owning compression does not change which bytes the provider accepts.
appendTrailingUserText verified to handle the transformed shape per protocol (transforms mutate roles/fields/steering/stamp, never the turn-array structure the applier parses).
Regression tests planned: proxy lane with configured compat.roles, the in-request learning facet (400 → hop → fake → hinted retry must carry the hopped role), plugin lane, plus a unit pin for hint-injection-on-transformed-shape. Follow-up with the PR link shortly.
Activity
ranxianglei commentedon Oct 2, 2026
[bot] 🏷 Triage: issue confirmed — root cause verified in code; one additional facet of the same mechanism found. Working on fix + regression tests.
Verification (master @ 6cab41b):
resolveFakeCompletion()call sites pass the raw clientbody: proxy streaming lanesrc/server.ts:6226, plugin lanesrc/server.ts:6120. The main forward of the same request shipswireBody(src/server.ts:5667) — post compat roles (billion-context: 400 Bad Request when codex sendsrole: "developer"messages — request a request-body compat transform hook #552/compat auto-fix: developer→system retry can still 400 on system-at-index-0 backends (#377 class); add second-chance developer→user learn #583), output steering (Feature: Output-side compression (verbosity steering + effort routing) #1093), dropFields (compat.dropFields:按 provider 删除客户端固定发送的字段(SenseNova Responses 严格 schema 400) #1757), chain stamp ([design] chain checkpoint step 3: carrier stamp shape on role-alternation-strict wires (anthropic/google) #1421) (applied at L5505–5553). The hinted retry therefore re-sends pre-rewrite bytes the provider already rejected in-session — exactly as described.wireBodyitself goes stale when the main attempt succeeded via a same-request re-send — the billion-context: 400 Bad Request when codex sendsrole: "developer"messages — request a request-body compat transform hook #552 role hop shipsfixed.body(L5771) and the 使用pi 压缩后就提示prompt is too long #1195 overflow refold shipsrefolded(L5906); neither updateswireBody. So passingwireBodyalone would still fail on the very turn where the role was learned in-request (first request of the session: 400 → hop → fake completion on that same turn → retry still carriesdeveloper). The fix covers both:wireBodynow tracks the last successfully sent body, and both call sites pass it.wireBody, so the retry must derive from that same accepted base; the agent owning compression does not change which bytes the provider accepts.appendTrailingUserTextverified to handle the transformed shape per protocol (transforms mutate roles/fields/steering/stamp, never the turn-array structure the applier parses).Regression tests planned: proxy lane with configured
compat.roles, the in-request learning facet (400 → hop → fake → hinted retry must carry the hopped role), plugin lane, plus a unit pin for hint-injection-on-transformed-shape. Follow-up with the PR link shortly.ranxianglei commentedon Oct 2, 2026
[bot] 🏷 已完成,PR 已开:#1904
按结构化七问作答:
1. 是什么问题:opt-in 的 fake-completion 纠正重试(
BILI_FAKE_COMPLETION_RETRIES > 0)从原始 client body 派生重试字节,而同一请求的主发送走的是 wireTransform 之后的wireBody。当 provider 已在会话早期拒绝过那些原始字节(learned compat roles,#552/#583)时,带 hint 的重试重发被拒字节 → 同样的 400 → 用户看到的是假完成而非纠正后的回合。审核确认属实(issue 描述与代码路径完全吻合)。2. 什么原因导致的:两个 call site(proxy lane + plugin lane)都把
forward()的原始body参数传给了resolveFakeCompletion,而不是主发送实际发出的wireBody——重试基座与主发送基座不一致。triage 中发现同机制的第二面:即使改传wireBody也不够——#552 role hop(fixed.body)和 #1195 overflow refold(refolded)在请求内重发成功时都没有更新wireBody,所以「角色是本次请求内学到的」那一回合,wireBody 仍是过期的预 hop 字节。两个缺陷同属「重试基座 ≠ 上游刚接受的字节」这一失败域,合并在本 issue/PR 内处理。3. 怎么修复的:① 两个 call site 改传
wireBody(opts 字段body→wireBody改名 + 文档块固化契约);② role-hop 与 refold 的 ok-branch 更新wireBody,确立不变量「wireBody = 最近一次成功发出的字节串」;③ plugin lane 对齐 proxy lane(在 call site 注释中显式记录该决定):hint 重试是 proxy→upstream 的 HTTP 调用,其基座必须是上游刚接受的字节,与哪一侧拥有压缩无关;相邻的makeContinuationRefetch({ body })用原始 agent body 是另一机制,保持不变。4. 是否有回归问题:无。逐条审过触碰路径的既有行为:#552 hop 阶梯、#1195 refold、#371/#473 fake-completion 检测+重试+streak 门控、plugin/proxy 双模式注入抑制——语义均未变,仅重试内容在 opt-in 路径上变为正确基座。新增 3 个 e2e 回归测试(configured compat roles / in-request learned 400→hop / plugin lane)+ 2 个单测 pin,全部验证过在未修复代码上失败、修复后通过;定向测试全绿(fake-completion 25/25、issue473 4/4、compat-roles+refold 19/19),typecheck 干净,全局套件交给 CI。行为变更披露:仅 opt-in 路径,旧=原始 client body+hint → 新=最后被接受的 wire 字节+hint——这就是修复本身;副作用是 reasoning-guard 等后续读
wireBody的地方从此读到被接受字节而非 pre-hop 字节(严格更正确)。5. 是否破坏缓存:不涉及。未触碰 prefix cache / prompt-cache key / 增量游标 / 去重键;chain-stamp digest 过期时走既有的 graceful strip 路径(#1421 已有机制)。
6. 是否改了设计方向:不涉及架构转向;只把「重试必须派生自主发送同一基座」这一契约显式化并补上两处漏更新的赋值。
7. 是否引入了新的配置:无。复用现有
compat.roles,无新 env/config/默认值。注意:测试选 Responses wire 承载 e2e 场景,因为 OpenAI-chat adapter 在 prepare 阶段就把
developer→system 归一化了,只有 Responses 保留 client 原始 role,场景才可表征——这是测试实现细节,不是产品限制。wire 行为变更(opt-in 路径),review-gated,不合并不由我执行。判定:可合并,等 owner review。ranxianglei commentedon Oct 2, 2026
[bot] 🏷 开放检查项(#1904 review 发现)— 同机制相邻面:degenerate-terminal continuation refetch 仍从 raw body 派生
来源: #1904 (PR) 分析 #1900 修复时发现
Review #1904 时确认 fake-completion 重试路径已被完整覆盖(两个 call site + hop/refold 的 wireBody 跟踪,不变量经枚举成立),但同一失败域——「请求内 proxy→upstream 重发派生自非上游刚接受的基座」——还有一个 PR 有意保留的相邻面:
makeContinuationRefetch({ body })的 4 个 call site(src/server.ts:6155、6179 plugin lane;6282、6322 proxy-mode strip pipe)。[BUG] In some cases, with Codex's auto model + DeepSeek, it will suddenly terminate automatically. #732/workbuddy报错Empty stream: upstream gateway sent only placeholder chunks without any model output (chunks=0, bytes=0) #821:回合以「无可见输出」结束时,重发原始 client body(+degenerate nudge)。wireBody是安全的——insertCheckpointCarrier(src/chain-checkpoint.ts,responses 分支)把 chain-stamp carrier 插在尾部compaction_trigger之前,故hasCompactionTrigger(src/degenerate-retry.ts)守卫在 stamped body 上依然成立;appendTrailingUserText按设计把 nudge 合并进尾部 user turn。待 owner 拍板:并入 #1904 合并前处理,或单独跟踪/处理。分析已备妥,两种走向都可直接执行。
Merge pull request #1904 from ranxianglei/2026-10-02_fake-completion-…
fix: derive fake-completion hinted retry from accepted wire bytes (ra…
fix(ranxianglei#2645): probe-and-remember prompt_cache_key at the egr…