[GH-ISSUE #3694] [Other] The agent's automatic compaction cannot compact a 65536-token window: compaction-basic's fixed 65536-token headroom leaves no pressure budget #1533

Closed
opened 2026-11-04 01:52:02 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @dai8647 on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3694

Area

[Other]

(The behaviour is in the agent runtime's compaction backend, not in the engine;
it is filed here because a local Strata engine on a 64K window is what triggers
it, and the engine is what most readers of this tracker run.)

Desktop app, Terminal or source?

Source (the harness plugin dsh-compaction-basic as shipped in the 0.2.1-rc.2
agent runtime, driving a locally built Strata engine).

What happened

dsh-compaction-basic's default headroomTokens is 65536, a fixed
number, while the threshold it computes is
min(0.8 * contextWindow, contextWindow - reservedCompletionTokens - headroomTokens).
On a model whose window is 65536 that leaves no pressure budget at all, so
the automatic compaction skips the target and the conversation runs into the
model's wall instead of being compacted:

compaction-basic: llamadock-strata/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS reserves 32768
completion tokens and 65536 headroom tokens of its 65536-token context window,
leaving no pressure budget; reduce the effective request maxTokens or compaction
headroomTokens, or configure a larger adapter model contextWindow

The step hook catches that error and continues the turn ("step compaction
failed: ...; continuing the turn"), so from the outside the only symptom is
that the context is never compacted: the reply gets cut at the model's window
and the client reports "output token limit reached".

Measured on a local engine behind an OpenAI-compatible server
(Windows, RX 7800 XT, 65536-token window, 32768 reserved output tokens):

  • with the default headroom: the session grew past 38,000 tokens, no summary
    request was ever made
    , and the reply was cut by the server's own window.
  • with headroomTokens: 4096: the same session compacted at 28,672 tokens -
    a summary request of 29,948 tokens, the session down to 12,475 tokens, and
    the engine's prompt cache at 99% reuse on the following turns.

The headroom is the one knob that decides whether a model with a 64K/128K
window can be compacted at all, and 65536 happens to be exactly the size of the
windows where it stops working.

Smallest steps or command that reproduce it

  1. Route any model with a 65536-token context window through the pi-ai adapter
    with contextWindow: 65536 and an output budget of 32768.
  2. Leave compaction-basic at its defaults (no headroomTokens).
  3. Grow the conversation past ~30,000 tokens.
  4. The compaction never runs; the request eventually hits the window.

Reproduction status

Deterministic: with the default headroom the compaction never fires on a
65536-token window, and with headroomTokens: 4096 it fires at 28,672 tokens
every time (measured on four runs, same binary).

Strata version

0.1.44.1 (the engine behind the agent runtime; the defect is in the harness
plugin, version 0.2.1-rc.2)

Graphics card, memory and system

RX 7800 XT 16 GB (gfx1101) · 96 GB RAM · Ryzen 5 5500 (AVX2) · Windows 11

Model, size and settings

Swift-Qwen3.8-Flash-Next IQ3_XXS (Swift-abliterated), pack packs/swift_mmap,
--max-context 65536 --vram-reserve-mib 1280, served through an
OpenAI-compatible endpoint on 127.0.0.1

Logs

(agent runtime, info level)
compaction-basic: llamadock-strata/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS reserves 32768
completion tokens and 65536 headroom tokens of its 65536-token context window,
leaving no pressure budget; reduce the effective request maxTokens or compaction
headroomTokens, or configure a larger adapter model contextWindow
step compaction failed: compaction-basic: ...; continuing the turn

A suggestion: scale the default headroom with the window instead of fixing it
at 65536 - e.g. headroomTokens = min(65536, floor(contextWindow / 4)) - so a
64K window keeps a pressure budget (16K headroom, a 16K threshold) and a 1M
window keeps the current behaviour. The threshold would then be
min(0.8*W, W - reserved - min(65536, W/4)), which stays in a sensible band
for every window size.

Originally created by @dai8647 on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3694 ### Area [Other] (The behaviour is in the agent runtime's compaction backend, not in the engine; it is filed here because a local Strata engine on a 64K window is what triggers it, and the engine is what most readers of this tracker run.) ### Desktop app, Terminal or source? Source (the harness plugin `dsh-compaction-basic` as shipped in the 0.2.1-rc.2 agent runtime, driving a locally built Strata engine). ### What happened `dsh-compaction-basic`'s **default `headroomTokens` is 65536**, a fixed number, while the threshold it computes is `min(0.8 * contextWindow, contextWindow - reservedCompletionTokens - headroomTokens)`. On a model whose window is 65536 that leaves **no pressure budget at all**, so the automatic compaction skips the target and the conversation runs into the model's wall instead of being compacted: ``` compaction-basic: llamadock-strata/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS reserves 32768 completion tokens and 65536 headroom tokens of its 65536-token context window, leaving no pressure budget; reduce the effective request maxTokens or compaction headroomTokens, or configure a larger adapter model contextWindow ``` The step hook catches that error and continues the turn ("step compaction failed: ...; continuing the turn"), so from the outside the only symptom is that the context is never compacted: the reply gets cut at the model's window and the client reports "output token limit reached". Measured on a local engine behind an OpenAI-compatible server (Windows, RX 7800 XT, 65536-token window, 32768 reserved output tokens): - with the default headroom: the session grew past 38,000 tokens, **no summary request was ever made**, and the reply was cut by the server's own window. - with `headroomTokens: 4096`: the same session compacted at 28,672 tokens - a summary request of 29,948 tokens, the session down to 12,475 tokens, and the engine's prompt cache at 99% reuse on the following turns. The headroom is the one knob that decides whether a model with a 64K/128K window can be compacted at all, and 65536 happens to be exactly the size of the windows where it stops working. ### Smallest steps or command that reproduce it 1. Route any model with a 65536-token context window through the pi-ai adapter with `contextWindow: 65536` and an output budget of 32768. 2. Leave `compaction-basic` at its defaults (no `headroomTokens`). 3. Grow the conversation past ~30,000 tokens. 4. The compaction never runs; the request eventually hits the window. ### Reproduction status Deterministic: with the default headroom the compaction never fires on a 65536-token window, and with `headroomTokens: 4096` it fires at 28,672 tokens every time (measured on four runs, same binary). ### Strata version 0.1.44.1 (the engine behind the agent runtime; the defect is in the harness plugin, version 0.2.1-rc.2) ### Graphics card, memory and system RX 7800 XT 16 GB (gfx1101) · 96 GB RAM · Ryzen 5 5500 (AVX2) · Windows 11 ### Model, size and settings Swift-Qwen3.8-Flash-Next IQ3_XXS (Swift-abliterated), pack `packs/swift_mmap`, `--max-context 65536 --vram-reserve-mib 1280`, served through an OpenAI-compatible endpoint on 127.0.0.1 ### Logs ``` (agent runtime, info level) compaction-basic: llamadock-strata/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS reserves 32768 completion tokens and 65536 headroom tokens of its 65536-token context window, leaving no pressure budget; reduce the effective request maxTokens or compaction headroomTokens, or configure a larger adapter model contextWindow step compaction failed: compaction-basic: ...; continuing the turn ``` A suggestion: scale the default headroom with the window instead of fixing it at 65536 - e.g. `headroomTokens = min(65536, floor(contextWindow / 4))` - so a 64K window keeps a pressure budget (16K headroom, a 16K threshold) and a 1M window keeps the current behaviour. The threshold would then be `min(0.8*W, W - reserved - min(65536, W/4))`, which stays in a sensible band for every window size.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 22, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".
  • Fill in "Reproduction status".
  • Fill in "Strata version".
  • Fill in "Graphics card, memory and system".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6334378802 --> @github-actions[bot] commented on GitHub (Oct 22, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". - [ ] Fill in "Reproduction status". - [ ] Fill in "Strata version". - [ ] Fill in "Graphics card, memory and system". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Oct 22, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6334491057 --> @github-actions[bot] commented on GitHub (Oct 22, 2026): Thanks, this follows the format now.
Author
Owner

@Niko1221 commented on GitHub (Oct 29, 2026):

Thank you. Fixed for Strata's own agent in 0.2.1: it sets the compaction headroom for each model from the window instead of the plugin's fixed 65,536. The headroom is a quarter of what the window has left after the reply room, and the reply room is half the window (at most 32K), so a 64K window can compact. If you run the plugin yourself, set headroomTokens the same way.

Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.1

<!-- gh-comment-id:6491893794 --> @Niko1221 commented on GitHub (Oct 29, 2026): Thank you. Fixed for Strata's own agent in 0.2.1: it sets the compaction headroom for each model from the window instead of the plugin's fixed 65,536. The headroom is a quarter of what the window has left after the reply room, and the reply room is half the window (at most 32K), so a 64K window can compact. If you run the plugin yourself, set `headroomTokens` the same way. Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.1
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1533
No description provided.