Repository navigation
Conversation
…ianglei#554 paragraph The first commit inserted the MODEL_HIDDEN_BODY_KEYS declaration in the middle of the ranxianglei#554 comment paragraph, orphaning the 'fails closed.' line below the new const. Move the declaration (with its own complete comment) after NON_TEXT_BODY_KEYS; no behavior change.
…ranxianglei#6844) Issue ranxianglei#6844 item 3: the measured-doom 413 lists four buckets, but 'other' is a catch-all — attributing it took manual arithmetic (the incident's 88%-other body needed a body dump to identify dsh_session_log). Independent of any exemption mechanism: the next unknown host-attached field will still 413, and the operator-facing message must say WHICH field is metered. - estimateRawBodyBreakdown tracks per-top-level-field token counts for the other bucket in the same single walk (new RawBodyBreakdown.otherTop, descending; empty when other is empty; top-level arrays attribute to no field, as before). - measuredBreakdownClause appends '(top field: <k> ~N)' when other is non-empty — all three 413 sites (egress fuse, preflight measured gate, fresh-session gate) inherit it. - raw-body-walk-depth shape pin updated for the additive otherTop field. - unit tests: per-field attribution + sum-to-bucket, hidden fields leave no attribution, clause naming + bare clause when other is empty.
- a body whose mass is a model-hidden DSH top-level field (5M-char dsh_session_log, ~1.25M measured tokens vs the 1M floored bar) forwards to the upstream — the incident shape no longer 413s; the fuse is a meter, not a filter, so the field still rides byte-exact; - an equally sized UNKNOWN top-level field still stops at the fuse (the exemption is a documented-field allowlist, not a hole — ranxianglei#3617 gate discipline) and the 413 names the dominating field.
(ai: vllm-qwen/qwen3.8-27b) Duplicate screening: Not a duplicate. The closest open PR is #6840 (fixes #6828) — different symptom (a body carrying the conversation under two protocol shapes at once double-counts the history) and different mechanism (a protocol-aware skip of the foreign conversation field), so it stays a separate issue. However #6840 and this PR both restructure the same top-level loop in Verified live (targeted, on the pushed head
Review (八问):
行为变更披露(旧值→新值+原因):
协调注意(重要,需 owner 定合入顺序): 本 PR 与 #6840 都改了 判定: 代码干净、测试有牙(正/负双向 + e2e both-ways)、无回归、行为变更已披露。本 PR 自身可合;与 #6840 的合入顺序需 owner 协调。 |
… dominating other (#6844) #6844's 88%-other body took a manual body dump to attribute: which host-attached field carries the non-prompt mass. estimateRawBodyBreakdown now tracks per-top-level-field token counts inside the other bucket (otherTop, descending) and measuredBreakdownClause names the dominating field in the 413 reason. No meter semantics change: total, the four buckets and prompt are byte-identical to before; otherTop is pure diagnostics. Ported from sx4im/billion-context PR #6860's otherTop diagnostic, which is independent of that PR's hardcoded-field exemption (superseded by the prompt-mass metering in bccd147).
… dominating other (#6844) #6844's 88%-other body took a manual body dump to attribute: which host-attached field carries the non-prompt mass. estimateRawBodyBreakdown now tracks per-top-level-field token counts inside the other bucket (otherTop, descending) and measuredBreakdownClause names the dominating field in the 413 reason. No meter semantics change: total, the four buckets and prompt are byte-identical to before; otherTop is pure diagnostics. Ported from sx4im/billion-context PR #6860's otherTop diagnostic, which is independent of that PR's hardcoded-field exemption (superseded by the prompt-mass metering in bccd147).
Resolve conflicts in src/preflight.ts: keep the PR's ranxianglei#6844 MODEL_HIDDEN_BODY_KEYS skip and otherTop per-field breakdown alongside main's isNonModelTopLevelKey skip in estimateRawBodyTokens and estimateRawBodyBreakdown; the 4-tuple pending walk keeps the PR's field tracking, main's Array.isArray guard included. src/server.ts merged clean.
The measured-body meter counted every top-level body field into
other, including DSH's model-hiddendsh_session_logdiagnostics. An ordinary request 413'd at the egress fuse withotherat 88% of the measured body while the model-visible buckets used 28% of budget.What changed:
estimateRawBodyBreakdownandestimateRawBodyTokensnow skip the two DSH model-hidden top-level fields (dsh_session_log,dsh_plugin_packages). The same key nested insidemessages[]is model-visible content and still counts. Genuinely oversizedotherfields are still counted.How verified: new regression test
tests/issue6844-measured-body-model-hidden-fields.test.ts(4/4, failed on master before the fix); neighbor suitesraw-body-walk-depthandside-request-isolationpass (45/45). Typecheck is clean in the changed files; twosession-gcfailures and fivedsh-tool-registration-lifetimetype errors reproduce on pristine master here (missing@deepseek-ai/cordisin this install) and are not from this change. Full suite is the CI gate.Additive review commits (ework-daemon, 2026-11-16)
Three commits added on top of the original fix (direction verified correct; all meter consumers consistent):
refactor:re-arranged the [Bug][dsh] measured-body egress fuse meters a model-hidden DSH field: 88% of a refused body was dsh_session_log inside the other bucket #6844 comment that the first commit had split out of the side request(max_tokens<=200)绕过 preflight 且不检查载荷体积,携带全量历史直转上游导致 400 #554 comment paragraph (no behavior change).fix:the 413 message now NAMES the field dominating theotherbucket (issue item 3, independent of any exemption mechanism):estimateRawBodyBreakdowntracks per-top-level-field token counts in the same single walk (additiveRawBodyBreakdown.otherTop, descending), andmeasuredBreakdownClauseappends(top field: <k> ~N)— all three 413 sites (egress fuse, preflight measured gate, fresh-session gate) inherit it.test:e2e both-ways fuse regression intests/issue4079-egress-window-fuse.test.ts— a body whose mass is a model-hidden DSH field forwards (the incident shape no longer 413s; the fuse is a meter, not a filter, so the field still rides byte-exact), while an equally sized UNKNOWN top-level field still 413s and names itself.Targeted suites green: issue6844 (8/8), issue4079 fuse (5/5), side-request-isolation + raw-body-walk-depth + fix-1075 (51/51), issue4185 (5/5), typecheck clean. Full-suite verdict = CI on the pushed head.
Behavior changes (old → new)
dsh_session_log/dsh_plugin_packagesbytes were previously priced into the measured body; now excluded fromestimateRawBodyTokens/estimateRawBodyBreakdown(top level only; nested occurrences still count; unknown fields still count — fail-safe). Affects every meter consumer: egress fuse, preflight measured gate, side-request guard,session.metadata.rawInputTokens. Reason: the fields are documented model-hidden provider metadata; the meter prices model input.other ~X→other ~X (top field: <k> ~N)(additive; only whenotheris non-empty). Tests match by regex prefix — no parse dependency.RawBodyBreakdowngains an additiveotherTopfield (thetotalinvariant== estimateRawBodyTokensis preserved and pinned).Open decision (see thread comment 🔶 需要决策)
The exemption is a library-maintained hardcoded set. An operator-configurable allowlist (config-surface change, needs owner sign-off) or a host-declared header (DSH-side change) are follow-up options — not implemented here.
Fixes #6844