Skip to content

[PR] fix(incremental): keep large seed envelopes on the incremental lane - #6681

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
mariopasquali:2026-11-14_incremental-large-seed
Nov 15, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
mariopasquali:2026-11-14_incremental-large-seed

Conversation

@mariopasquali

Copy link
Copy Markdown
Contributor

(ai: claude-opus-5-5)

incrementalTurnBodyShape refuses any body over 64 MiB. The client-side check it mirrors (incrementalEnvelopeConversationId) has no size limit, so a marked turn whose seed envelope crosses 64 MiB is classified as lane traffic by the client but as an ordinary request by the server. The server then replays the envelope through the normal pipeline to the upstream provider, which isn't a valid model request, and the turn fails. Long sessions reach this on their first (seed) turn.

The receive-size budget is already enforced by readBody (limitsReceiveBytes, 5 GiB default, 413 on overflow) before the shape check runs, so the second limit only adds a gap between 64 MiB and that budget. This PR removes it.

Test: tests/incremental-large-body.test.ts covers a >64 MiB envelope (must classify as lane traffic) and a >64 MiB ordinary marked request (must stay ordinary). The first case fails on master and passes with the change. tests/incremental-lane.test.ts and tests/opencode-incremental.test.ts pass, and so does npm run typecheck. Full CI was not run locally.

@ranxianglei ranxianglei changed the title fix(incremental): keep large seed envelopes on the incremental lane [PR] fix(incremental): keep large seed envelopes on the incremental lane Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Review — fix(incremental): keep large seed envelopes on the incremental lane

Independent review: I re-derived the bug from the code (not from the description), verified the fix's safety argument, and ran the targeted suites locally.

What I verified

  • The bug is real. Server-side incrementalTurnBodyShape (src/incremental-lane.ts:80) had a raw.length > 64 MiB cap; the client-side mirror it's supposed to track, incrementalEnvelopeConversationId (src/agent/incremental-client.ts:109), has no size cap. A marked seed envelope over 64 MiB is therefore lane traffic to the client but an ordinary request to the server → replayed through the normal pipeline (src/server/handle.ts:281) as a non-model body → the turn fails. Long sessions hit it on the first (seed) turn.
  • The fix is correct and the safety argument holds. Removing the cap makes both sides classify on shape only. The receive-size budget is enforced before the shape check: readBody (src/server.ts:4810) rejects via BodyTooLargeError/413 at limitsReceiveBytes (5 GiB default, src/knobs.ts:282/302), and handle.ts calls readBody (:237) before incrementalTurnBodyShape (:255). So a hard cap remains; the 64 MiB line was a redundant second limit that only opened a mismatch gap.
  • No other sync points. The remaining 64 * 1024 * 1024 literals (src/knobs.ts:514 session-warm budget, src/cache-keepalive.ts:39 snapshot cap) are unrelated to lane classification.
  • Tests are real and bidirectional (gate discipline): a >64 MiB lane envelope must classify as lane traffic; a >64 MiB ordinary marked request must stay ordinary. The whitespace-padding trick crosses the threshold without building a huge nested object.
  • Local evidence: the new test fails on master (expected true, got false) and passes with the change; tests/incremental-lane.test.ts + tests/opencode-incremental.test.ts (26 tests) pass; npm run typecheck clean. Branch is current with master (0 commits behind). Full CI is still queued on the pushed head (22 checks pending) — remote CI is the authoritative full-suite verdict.

Minor note (not a blocker): for a large (>64 MiB) ordinary marked request the body is now parsed twice (shape check + pipeline) where it was parsed once before. That's a rare path (marked incremental turns over 64 MiB that are ordinary) and the body is bounded by the 5 GiB receive budget, so it's a negligible CPU cost — not a behavior regression.


结构化八问(中文,供人工 reviewer):

  1. 是什么问题: 增量车道里,客户端标记为车道流量的大种子信封(>64 MiB)被服务端误判为普通请求,回放给上游后不是合法模型请求,该轮失败;长会话的种子轮(第一轮)会触发。
  2. 什么原因导致的: 服务端 incrementalTurnBodyShape 带 64 MiB 大小上限,而它镜像的客户端检查 incrementalEnvelopeConversationId 没有大小上限——两端分类不一致,大信封被客户端当车道流量、被服务端当普通请求。
  3. 影响范围与严重程度: 特定条件下有问题——仅当标记轮的信封 >64 MiB(长会话种子轮)时该轮失败;短会话不受影响。严重度:该条件下种子轮不可用。
  4. 怎么修复的: 移除服务端 64 MiB 上限,让服务端与客户端分类对齐(都只看形状、不看大小);接收大小预算已由 readBody(5 GiB 默认、超限 413)在形状检查之前先行强制,移除后仍有硬上限。
  5. 是否有回归问题: 无行为回归。只改变 >64 MiB 正文:合法车道信封 → 车道流量(即本修复);普通带标记请求 → 形状检查 → 仍为普通(行为不变)。唯一代价:大(>64 MiB)普通带标记请求现在解析两次(形状检查+管道),属罕见路径的轻微 CPU 开销,非语义/阈值/时序/输出格式漂移。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及——只是让两端分类对齐,无架构/边界/数据流转向。
  8. 是否引入了新的配置: 不涉及。

判定: 可合(本地定向测试 + typecheck 全绿;全量 CI 仍 queued,以远程 CI 为准)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Status update (full review is the comment above):

  • CI progress: all guard lanes green — lock-sync, lane-guard, unused-exports, lifecycle-ledger-guard, architecture-docs, mysql-contract all success; 0 failures so far. The 11 sharded test lanes (ubuntu/windows × node 22/24) + 2 static-gates are still queued — the full-suite verdict is still pending.
  • Local verdict stands: the new test fails on master / passes with the change, 26 related tests pass, typecheck clean, branch current with master.
  • Verdict unchanged: 可合 — mergeable on the local evidence; the remote test lanes are the final full-suite confirmation. No action needed from me; the PR author / a human merges.

@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6765 (merged to master as f24173e).

Your commit baee51f is in master verbatim — same content, same authorship, only the object ID changed (the batch used a real git merge, no rebase or cherry-pick rewrite). Merged under a different branch name, so GitHub does not flip this PR by itself.

Thanks for the fix — it is live in master from f24173e onward.

(Your source branch was deleted after the merge, which is why GitHub could not detect the ancestor relationship either — tip baee51f is an ancestor of master.)

@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6765 (merged to master as f24173e). Your commit baee51f is in master verbatim — same content, same authorship, only the object ID changed (real git merge, no rebase/cherry-pick rewrite). Your source branch was deleted after the merge, which is why GitHub could not detect the ancestor relationship — tip baee51f is an ancestor of master. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants