Repository navigation
[PR] fix: un-show a nudge whose request the upstream rejected - #6531
ranxianglei merged 1 commit into
Conversation
The kernel stamps a nudge as shown when it decides to inject it, before the request goes upstream. When the upstream rejects that request (a Claude Code session on v0.1.213, 2026-11-11: the nudge drew "role 'system' must precede an 'assistant' message"), the model never saw the nudge, yet the stamp holds the cadence as if it had: the next request was smaller than the rejected one, the decision read "growth=-21002 ... blocked: T1 (cadence)", and the next nudge waits until the context grows a full growth floor past the rejected request. On a 4xx for a request that carried a nudge, roll the shown stamps back to their pre-turn values and hold nudges until a request succeeds, so the next request goes out without the nudge that may have drawn the 400, and the turn after a success re-decides from the old reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Reviewed the diff, the kernel stamping mechanism, and the new test. I also ran the test locally on both master and the PR head to verify the regression claim. Verdict: mergeable. The fix is correct for the reported repro, the test is a genuine regression test, CI is green, and the code follows repo conventions. The notes below are non-blocking. What I verified
Non-blocking notes
No config, persistence-format, wire-shape, or kernel change; the new conjunct sits outside 审核八问
结论:可合。 修复正确、回归测试真实(master 红 / 修复后绿,已本地复跑)、CI 全绿;上述 3/4/5/6 为不阻塞的说明与后续项(4 建议记入 #6530 跟进)。 |
|
(ai: vllm-qwen/qwen3.8-27b) Reviewed. APPROVE for human merge. The fix is correct and well-scoped: snapshot the nudge stamps before the request goes out, roll them back on a 4xx rejection, hold further nudges until a request succeeds, then re-arm. Verified:
Non-blocking findings:
Diff clean, code follows repo conventions. No kernel/config/persistence/wire-shape change. Full 8-question review: #6532 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Acknowledged — thanks for the review and approval. The PR is ready for human merge (merging is human-only per repo rules, so I won't touch the merge button). On the two findings beyond what I'd flagged:
The one actionable item for the PR body before merge is the plugin-mode prose correction (finding 1): per #451 the nudge is injected in both modes, so "the proxy injects no nudge … nothing changes" should be reworded to say the fix is mode-agnostic. |
…nes too (#6531) The reject re-arm from #6531 only captured the cadence stamps in the anthropic lane, but the nudge rides every protocol lane (all four prepare-* files can set nudgeOutcome = "injected") — a 4xx reject on any other lane kept the stale shown-stamp and starved the cadence exactly as the issue describes. Mirror the anthropic-lane pattern into prepare-google/openai/responses: snapshot before processTurn, restore while the hold flag is set, veto injection while held, expose nudgeStampsBefore only when actually injected. The relay 4xx hook (rejectNudge) is lane-agnostic, so no relay change is needed. Tests: consecutive-4xx idempotency (a second 4xx must neither re-restore the stamps nor clear the hold; the nudge re-arms exactly once after the usage-settled success) and a full google-lane re-arm e2e (reject -> hold -> re-arm), alongside the existing anthropic pair.
#6531) Review finding on the #6531 extension: the hold flag was only cleared by settleUsageReport for s.total > 0 samples, so on upstreams that never report usage (#1595 route class) a single 4xx on a nudge request latched the hold for the rest of the process lifetime — the exact failure #6531 fixes, relocated. Clear it at every no-usage success site (proxy-json, acp-loop, the three plugin lanes) via releaseNudgeHold, matching the documented 'hold until the next success' contract. New e2e test: a stream with no usage fields at all, one rejected nudge, hold released by the first no-usage 200, nudge re-armed on the following turn. Verified the test fails without the fix (3 pass / 1 fail) and passes with it (4/4); tsc clean; sibling suites green (overflow-refold 9/0, google progress 5/0, phantom-read 2/0, drain-audit 9/0).
|
Heads-up from the batch-merge review (this PR will land via the batch PR, which fixes two issues found in this one before merging — the fixes will be noted in the superseded comment after the merge): 1. The re-arm was Anthropic-lane only, but the nudge rides every protocol lane. 2. The hold flag latches forever on upstreams that never report usage (major). Both fixes carry new end-to-end tests in |
(ai: vllm-qwen/qwen3.8-27b) Acknowledged — thanks for the heads-up. I independently verified the batch branch before confirming (not just trusting the commit messages). State confirmed
CI: PR #6765 checks are running (6 success / 11 in progress / 13 skipped, 0 failure at last mirror fetch). The batch PR's CI is the authoritative gate for the merge. On #6531's own branch: the earlier conflict-resolution takeover is now moot — it lands via the batch PR, so no rebase/conflict work is needed on the contributor's branch. I won't touch the merge (human-only) or close it (owner-only). 审核八问
结论:可随 batch PR(#6765)合入。 两处修复已在 batch 分支落地并经我独立核对(代码 + 4 个 e2e 测试齐全、机制自洽),#6531 自身分支不再需要冲突处理;合入后按约定在 superseded 评论补记两处修复即可。 |
(ai: vllm-qwen/qwen3.8-27b) Not rebasing this branch this run — the conflict-resolution is moot. Live verification first (mirror cache, fetched ~05:27Z this run):
Why I'm not doing the rebase + force-push: The owner's floor-14 decision (2026-11-15 05:13Z) is explicit: "this PR will land via the batch PR, which fixes two issues found in this one before merging." That decision still holds — the batch PR #6765 is still open and in progress at the same tip, still carrying the #6531 changes. So the contributor's own branch does not need to be rebased to land; it will be superseded by the batch PR. Rebasing + force-pushing this branch now would be (1) unnecessary — the changes already land via #6765; and (2) risky — force-pushing onto a superseded external contributor's branch, exactly the case the push-discipline note warns about (other agents may be working on the branch concurrently). Action: stopping without touching the branch. No rebase, no force-push, no needs-decision label (this is not an open design decision — the owner already decided the landing path). If the intent has changed and #6531 should instead merge directly on its own branch (not via the batch PR), confirm in-thread and I'll do the rebase + conflict resolution in a follow-up run. |
[ework] CI fix verified green ✓ |
|
Closes pair #6530 was auto-closed by the batch merge. Superseded by #6765 (merged to master as 89a671e). Your commit 99966e2 is in master verbatim — same content, same authorship, only the object ID changed (the batch used a real Thanks for the fix — it is live in master from 89a671e onward. Note: review found two gaps, both fixed on the batch branch before merge (full details in the Heads-up comment above): 938040f extends the re-arm to the google/openai/responses lanes (the nudge rides all four), and 4c8824e releases the hold on no-usage successes (it latched forever on upstreams that never report usage). |
Master advanced 379 commits (incl. nudge-rearm #6531, side-passthrough, preflight/fold, relay output-budget #6529) since the prior sync (9674cfa). 4 of the PR's 5 files overlapped; 3 auto-merged cleanly. The one conflict, src/server/prepare-anthropic.ts, resolved as the union of both intents: keep #4974's if (!anthropicTitleGen) gate wrapping the meter writes (the meter writes are byte-identical on both sides modulo indent) and adopt master's return which adds nudgeStampsBefore (nudge-rearm #6531). typecheck clean; issue4974 + side-lane-invariants + issue2490 + issue2847 = 30/30 and anthropic nudge suites = 7/7 pass.
Master advanced 68 commits (nudge-rearm #6531 recordNudgeInject, nudge-debug, responses-system-sections, cache-ledger recovery, …) since the prior sync (2e3cfc9). 2 of the PR's 5 files overlapped (prepare-anthropic.ts, relay.ts); relay auto-merged cleanly. The one conflict, prepare-anthropic.ts, resolved as the union of both intents: keep #4974's if (!anthropicTitleGen) gate wrapping the meter writes (localInputEstimate / lastLocalTextEstimate / probeRequest Membership / lastLocalTextEstimateOrigin) and adopt master's new recordNudgeInject call OUTSIDE the gate — it is a cache-ledger recovery event (nudge tracking, #6531), a separate concern from the meter the #4974 gate protects. typecheck clean; issue4974 + side-lane-invariants + issue2490 + issue2847 + issue6720-nudge-recovery = 41/41 and anthropic nudge suites = 7/7.
Fixes #6530
Problem
The kernel stamps a nudge as shown when it decides to inject it, before the request goes upstream. When the upstream rejects that request (4xx), the model never saw the nudge, yet the stamp holds the cadence as if it had: the next nudge waits until the context grows a full growth floor past the rejected request (22,500 tokens at the default cadence), and longer when the client's next request is smaller. Seen in a Claude Code session on 0.1.213 after a #5432 400 (
growth=-21002 ... blocked: T1 (cadence)); any 4xx produces it.Fix (host side, no kernel change)
src/server/prepare-anthropic.tsrecords the nudge stamps from before the turn (nudgeStampsBefore) only when the request carries an injected nudge.src/server/relay.ts: on a 4xx for such a request,rejectNudge(src/session.ts) restoreslastNudgeShownTokens/lastShownByTierand setstransient.nudgeHeldAfterReject.src/cache-ledger.tsclears the hold when a request succeeds, and the next turn decides from the old reference.infolog line per rejection:nudge rejected with its request (upstream 400): stamps rolled back ....Both compression modes
nudgeStampsBeforeis never set and nothing changes.The fix covers the Anthropic wire only.
prepare-openai.ts,prepare-responses.tsandprepare-google.tsdo not record stamps, so they behave as before. Extending them is a follow-up if the maintainers want it.Tests
tests/rejected-nudge-rearm.test.ts(new): sends a smaller request after the 400, as the client did. It fails on master (after a request succeeds, the undelivered nudge is re-armed), passes with the fix, and checks that a delivered nudge is not re-armed.npm run typecheckclean.ACP_TEST_E2E=1). This touches the relay path, so the maintainers may want that lane before merge.Review tier
This touches nudge cadence state in the session, so per §7.4 it stays with a human reviewer rather than auto-merge. No config, persistence-format, wire-shape or kernel change.
🤖 Generated with Claude Code