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
[Feature][dsh] Ingestion cost band needs an advance-warning line — sessions cross 32 MiB silently and die at 413 with no self-rescue #7232
The #5794 gate (default network.ingestBodyBytes = 32 MiB, refusal stage=ingest) is the right fuse — I've seen the 51.2 MiB / 747s-FATAL incident class it prevents. But the user experience around the line has two gaps:
No advance warning. On DSH the host resends the full raw transcript every round, so the inbound body grows monotonically with session age, completely decoupled from how well bili folds (my case tonight: 344 blocks, outbound 161K tok, 99% cache hit — a model ledger student — died at 33,564,991 B, 0.03% over the band). Nothing told the user at, say, 26 MiB (80%) that the session is approaching the terminal line; the first and only signal is the 413 itself, rendered as raw JSON in the composer.
No self-rescue. The gate refuses before preflight/nudge/compress can run, so bili — the only component holding the folded ledger and knowing exactly which raw ranges can be retired — cannot offer to shrink what the host resends. The message says "reduce the session history — restart or rewind", both of which are user-side archaeology; bili has the ledger to do it itself (acp_retire/acp_restore from [PR] feat: compress-block retirement (acp_retire/acp_restore) + external summary rewrite (acp_rewrite) + export ledger #5774 already exist; an opt-in "retire-raw-tail when inbound ≥ N% of band" bridge, or at least a loud advisory nudge carrying the exact byte distance to the wall, would convert a silent brick into a managed rollover).
Proposed shape (either or both):
advisory injection once inbound raw body ≥ warnFraction (config, default off, e.g. 0.8 of network.ingestBodyBytes), one-time per session per threshold, carrying current MiB and the action to take;
an explicit "history rollover" helper: bili authors a compressed continuation view from its own ledger when the band would be hit twice (fail-open preserved).
Repro evidence in #6781 comment (2026-11-19) and #6122 comments (2026-11-13). bili 0.1.214+ / DSH desktop / Windows / protocol=openai.
Duplicate screening: no duplicates. Searched open+closed issues for "ingestBodyBytes 413", "ingest band warning", "history rollover continuation retire raw tail", "5794 ingest body too large dsh full resend", "ingest band advance warning advisory nudge byte distance" — no matches. This is a new feature request.
Labels applied:p2, dsh, scope/wiring — p2 because the session works fine until the band is hit (not a crash/data-loss/permanent-unavailable), dsh because the repro is DSH desktop, scope/wiring because the ingest gate lives in the request pipeline (src/server/handle.ts).
Evaluation — this is a real gap, and the two proposed shapes are not equally tractable.
I read the code at the relevant points. Here is what I found:
The gate (src/server/handle.ts:537-541) fires after decode, before the JSON.parse sweep. At that moment bili knows the body byte length and (for plugin hosts like DSH) the session id is already available from the request headers. So the "advance warning" is architecturally feasible — the session id is present, the advisory/nudge machinery exists, and the byte distance to the wall is trivially computable (ingestBodyBytes - body.byteLength).
The "retire-raw-tail" premise is a misunderstanding.acp_retire / retireBlocks (kernel/src/block-ops.ts:44-64) only flips block.retired = true — summaries leave the resident view (what's sent to the model, i.e. outbound). It does NOT touch the inbound body. On DSH the host resends the entire raw transcript every round (confirmed by code comments at handle.ts:2783 and persist.ts:4165), so the inbound body is controlled by the host, independent of bili's resident view. Retiring blocks in bili's ledger will not shrink what the host sends.
The "history rollover" idea (bili authors a compressed continuation view from its own ledger) is the right direction, but it is a session-identity change that requires host cooperation — the host would need to accept a new session id and a truncated transcript. That is high-risk, §7.4 human-gated, and not something that can be shipped as a config knob.
Recommendation: ship the advance warning first, track the self-rescue as separate work.
Part 1 — Advance warning (ship now):
New config knob: network.ingestWarnFraction (default 0 = off, e.g. 0.8 to warn at 80% of network.ingestBodyBytes).
Fires once per session per threshold cross (track sessionId → lastWarnedFraction in session state).
Carries: current MiB, the band limit, the byte distance to the wall, and the action to take ("restart the session or rewind to an earlier point, or set network.ingestBodyBytes higher").
Injection point: the gate at handle.ts:537 — when body.byteLength >= warnFraction * ingestCap and the warning hasn't fired yet for this session, inject the advisory into the response (the existing nudge/advisory machinery handles delivery).
Config surface: one new field under network.ingestBodyBytes, following the existing knob pattern in src/knobs.ts.
Part 2 — Self-rescue / history rollover (track as separate work):
The "retire-raw-tail" idea as stated won't work (see above).
The "history rollover" idea is the right direction but requires host cooperation (new session id, truncated transcript acceptance). This is a protocol-level change, not a config knob.
Suggested next step: file a separate issue for the history-rollover design, with the constraint that it must fail-open (if the host doesn't accept the continuation, the session continues as-is until the band is hit).
Decision request for the owner:
Approve Part 1 (advance warning) for implementation? The config knob network.ingestWarnFraction (default off) is the only new surface.
For Part 2, should I file a separate issue for the history-rollover design, or fold it into this issue's scope?
I can start implementing Part 1 immediately on your go.
Activity
ranxianglei commentedon Nov 18, 2026
[bot] 🏷
(ai: opencode/qwen3.8-27b)
Duplicate screening: no duplicates. Searched open+closed issues for "ingestBodyBytes 413", "ingest band warning", "history rollover continuation retire raw tail", "5794 ingest body too large dsh full resend", "ingest band advance warning advisory nudge byte distance" — no matches. This is a new feature request.
Labels applied:
p2,dsh,scope/wiring— p2 because the session works fine until the band is hit (not a crash/data-loss/permanent-unavailable), dsh because the repro is DSH desktop, scope/wiring because the ingest gate lives in the request pipeline (src/server/handle.ts).Evaluation — this is a real gap, and the two proposed shapes are not equally tractable.
I read the code at the relevant points. Here is what I found:
The gate (
src/server/handle.ts:537-541) fires after decode, before the JSON.parse sweep. At that moment bili knows the body byte length and (for plugin hosts like DSH) the session id is already available from the request headers. So the "advance warning" is architecturally feasible — the session id is present, the advisory/nudge machinery exists, and the byte distance to the wall is trivially computable (ingestBodyBytes - body.byteLength).The "retire-raw-tail" premise is a misunderstanding.
acp_retire/retireBlocks(kernel/src/block-ops.ts:44-64) only flipsblock.retired = true— summaries leave the resident view (what's sent to the model, i.e. outbound). It does NOT touch the inbound body. On DSH the host resends the entire raw transcript every round (confirmed by code comments athandle.ts:2783andpersist.ts:4165), so the inbound body is controlled by the host, independent of bili's resident view. Retiring blocks in bili's ledger will not shrink what the host sends.The "history rollover" idea (bili authors a compressed continuation view from its own ledger) is the right direction, but it is a session-identity change that requires host cooperation — the host would need to accept a new session id and a truncated transcript. That is high-risk, §7.4 human-gated, and not something that can be shipped as a config knob.
Recommendation: ship the advance warning first, track the self-rescue as separate work.
Part 1 — Advance warning (ship now):
network.ingestWarnFraction(default0= off, e.g.0.8to warn at 80% ofnetwork.ingestBodyBytes).sessionId → lastWarnedFractionin session state).network.ingestBodyByteshigher").handle.ts:537— whenbody.byteLength >= warnFraction * ingestCapand the warning hasn't fired yet for this session, inject the advisory into the response (the existing nudge/advisory machinery handles delivery).network.ingestBodyBytes, following the existing knob pattern insrc/knobs.ts.Part 2 — Self-rescue / history rollover (track as separate work):
Decision request for the owner:
network.ingestWarnFraction(default off) is the only new surface.I can start implementing Part 1 immediately on your go.