Repository navigation
[PR] Make a held head dropped at drain auditable (#5192) - #6537
ranxianglei merged 2 commits into
Conversation
The streaming tag filter reports its drops through a one-shot notice: the first drop of a response claims it and every later one is silent. A tag head still held when the stream ends is dropped inside flush(), so when a completed tag came first (the common case) the drain drop produced a counter bump and no line at all — the only trace was the strip snippet, which is why a 5-char "<acp " in bili.log was indistinguishable from a successful strip. Give drain drops their own budget and an explicit second argument on the onDrop callback so every caller can name the event: the filter now reports a drop made during flush() as "held head dropped during drain", while the one-shot notice for ordinary strips keeps its current semantics (still one line per response). Refs ranxianglei#5192.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) PR #6537 review in progress — interim status: Verified so far:
Gap found (extending the fix now): Per 连贯修复不拆片 (one mechanism = one PR), I'm extending the fix to cover the swallow-span EOF drop sites. Remaining: flag the 7 swallow-span EOF call sites, add tests, run, push to the PR branch, then post the full 八问 review. |
The original PR flagged only the TRUNC_OPEN/TRUNC_CLOSE settle-branch sites (a truncated tag head held at EOF). The swallow-span EOF drops (stream dies mid-tag AFTER a complete opening tag — the more common died-mid-tag shape) still went through dropSwallowSpan with duringDrain=false and produced no drain line. Extend the duringDrain flag to dropSwallowSpan and pass true at all 7 swallow-span EOF call sites (lines 1537, 1546, 1551, 1554, 1579, 1585, 1594). Add 2 regression tests for the swallow-span drain case. Per 连贯修复不拆片: one mechanism (drain-drop auditability) = one PR.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) PR #6537 Review — "Make a held head dropped at drain auditable (#5192)"查重: 不重复。PR 是 #5192 的一个可审计切面(owner 裁定所有切面留在 #5192 下),PR 本身不 claim Review 结论: 机制正确,但原始 PR 只覆盖了 EOF drop 站点的一部分。我直接扩展了修复(见下方说明),已 push 到 PR 分支。 我做了什么(扩展说明)原始 PR 只 flag 了 Probe 确认:stream 在 按 连贯修复不拆片(一个机制 = 一个 PR),我扩展了修复:
行为变更披露:swallow-span EOF drop 从"静默丢弃"变为"产生一条 八问
判定可合。机制正确,测试充分(9/9 通过 + 83/83 回归),diff 干净(2 files, +35/−9 扩展部分),无回归。扩展部分已 push 到 PR 分支(commit |
|
Superseded by #6765 (merged to master as fcee1c0). Your commit 296e2c0 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 fcee1c0 onward. |
What this changes
The streaming tag filter reports drops through a one-shot notice:
recordDropfiresonDropfor the first drop of a response and then never again. A tag head still held when the stream ends is dropped insideflush(), so whenever a completed tag came first — the common case — the drain drop produced adropCountbump and no log line at all.This gives drain drops their own budget and an explicit flag on the callback:
const recordDrop = (snippet: string, duringDrain = false) => { droppedAny = true; + if (duringDrain) { + if (onDrop && !drainNoticed) { drainNoticed = true; onDrop(snippet, true); } + return; + } if (onDrop && !notified) { notified = true; onDrop(snippet); } };The two drop sites that resolve a held tail at EOF (
TRUNC_OPENandTRUNC_CLOSEin theflush()settle branch,src/loop/tag-echo-filter.ts:1608-1617) pass the flag; all eight callers name the event in their own wording. Ordinary strips keep the one-shot semantics untouched — still exactly one line per response.Why
Field evidence from #5192. In a 40-truncation session, 36
stripped model-emitted render taglines were logged and 35 of them carried a full opening tag. The one exception was five characters long:That line is the drained head — the same fragment the persisted assistant text then carried as prose (
1-13 17:51:02">m00582). But because it rendered with the identical wording and prefix as a successful strip, it was indistinguishable from one, and the second and later drain drops of that session left no line at all. An operator readingbili.loghad no way to tell "tag stripped cleanly" from "stream died mid-tag".Naming the event is the whole point: a drain drop means the stream ended while the filter still held bytes, which is a truncation symptom, not a strip.
Reproduction (red before the fix)
tests/issue5192-drain-head-audit.test.ts— six unit tests against the filter plus one end-to-end test throughpipePluginChatWithStrip. Against the unpatched filter, 4 of the 7 fail:With the fix: 7/7, and the emitted line is
The end-to-end case asserts both directions: the completed tag still produces exactly one
stripped model-emitted render tagline, the drained head produces exactly oneheld head dropped during drainline, and the prose around both survives byte-for-byte.Verification
npx tsc --noEmit --project tsconfig.json→ exit 0issue5192-drain-head-audit,tag-echo,verif-tag-echo-filter,issue2190-degen-close,issue4164-dead-ref-chunk-boundary,issue1881-reasoning-tag-leak,plugin-passthrough-tag-strip-chat,plugin-passthrough-progress-frame,plugin-passthrough-progress-frame-google,plugin-passthrough-finish-tail,plugin-passthrough-tag-strip)duringDrainarguments in the filter: 4 fail, then 7/7 after restoretests/advisory.test.tshas one pre-existing failure (checkForUpdate: a forced manual update bypasses the first-check deferral,4 !== 3fetch calls); it reproduces on a cleanmasterstash, so it is unrelated to this changeScope
One module (
src/loop/tag-echo-filter.ts, +18/−6) plus the callback wording at its eight call sites (src/plugin.ts, five adapters) and one new test file. The new parameter is optional and additive — noTagEchoFilterStatsfield, so no consumer (composeStreamFiltersstats merge,maybeWarnDegenerate,degenerateTurnWarning) needs to change, and no config surface or wire shape moves. Noversionbump.Fixes #5192is deliberately not claimed — the owner's ruling keeps all facets under that issue; this PR only makes one facet observable.Related
type="text">mNNNNNinto assistant text #5192 — the family this belongs to (this comment proposed the change: "Makeflush()'s drop auditable")