[GH-ISSUE #3753] [TUI] connect pi: compaction occurs at 15,000 tokens regardless of context window size #1578

Closed
opened 2026-11-04 01:52:22 +07:00 by bsakaguchi · 1 comment
Owner

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

Area

[TUI]

(strata connect is the Terminal's connect command.)

Desktop app, Terminal or source?

Terminal (the strata command)

What happened

strata connect pi writes a compaction.reserveTokens that grows with the served context window. In pi,
reserveTokens is headroom it keeps free for the response, not a conversation budget, so a reserve that
scales with the window makes the compaction trigger stay at 15,000 tokens whatever the window is.

On my 128K session pi compacted after about 15,000 tokens of a 131,072-token window, then kept compacting
every turn or two after that. The 116K of the window I had paid for was never used.

pi's own reference says the reserve is fixed headroom and does not scale:

   Auto-compaction triggers when:
       contextTokens > contextWindow - reserveTokens
   By default, `reserveTokens` is 16384 tokens (configurable in ~/.pi/agent/settings.json …).
   This leaves room for the LLM's response.

docs/compaction.md of pi 1.1.0, and pi 1.1.0's default in its own settings-manager is 16384 for every model.

Strata writes instead (strata_cli/launch/harness.py, pi_settings, line 134):

   "reserveTokens": max(1024, t.context - COMPACT_AT)      # COMPACT_AT = 15000, harness.py:24

Values strata connect pi prints for the same model at each served window (measured on my machine):

   --context 32k   reserveTokens  17,768   pi compacts above  15,000   45.8% of the window used
   --context 64k   reserveTokens  50,536   pi compacts above  15,000   22.9% of the window used
   --context 128k  reserveTokens 116,072   pi compacts above  15,000   11.4% of the window used

Expected: at 128K the app should keep most of the window for the conversation and compact when the
window is close to full, the way pi's own default does at every window size.
Actual: it compacts at 15,000 tokens, and nothing on screen says a line at 15,000 was chosen:
the limits text for pi (harness.py:182) says the same "about 15K tokens before it summarises" at 128K as
at 32K, so the config read back to me looked reasonable.

The 32K case is the only one that was ever measured: harness.py's own docstring (line 3) says the eight
configs come from configs "tested for real against a Strata server at 32K context". So this is the
tested 32K constant applied unchanged to windows nobody checked, written in the one app's unit where it
becomes a meaningless number.

The presence of the key is right and should stay: for other apps the app's own default is broken for a
local model (without limit.input OpenCode never compacts, and Claude Code without
CLAUDE_CODE_MAX_CONTEXT_TOKENS "never compacts, or compacts on every turn"). It is the value at
non-32K windows that is wrong.

Smallest steps or command that reproduce it

No GPU and no download needed to see the value written:

   strata connect pi --context 128k --output json
   #   "contextWindow": 131072 … "reserveTokens": 116072
   strata connect pi --context 64k  --output json
   #   "contextWindow": 65536  … "reserveTokens": 50536
   strata connect pi                  # my saved preset, 32K, prints 17768

To see the behaviour in pi itself: strata connect pi --write --yes, start a session and watch the first
/compact-style summary land near 15,000 tokens of a 131,072-token window rather than near the end.

Workaround I used: after strata connect pi wrote the file I set compaction.reserveTokens by hand back
to a fixed headroom and left everything else as written.

Reproduction status

Reproduced locally for the values strata connect prints and for the early compaction in my 128K session.
pi's trigger formula and its 16384 default are read from pi 1.1.0's own docs and settings-manager on my
machine, not re-derived from a Strata run. I did not test a 64K pi session and did not measure any
engine-side cost of the extra compactions.

Strata version

strata 0.2.2 (build 0.1.47) — from strata --version.
pi 1.1.0 (npm install -g @earendil-works/pi-coding-agent today); strata connect pi --check reports
this config was tested with pi 0.74.2, so the pi version I read the semantics from is not the one
the config was tested against.

Originally created by @dnnkeeper on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3753 ### Area [TUI] (`strata connect` is the Terminal's connect command.) ### Desktop app, Terminal or source? Terminal (the `strata` command) ### What happened `strata connect pi` writes a `compaction.reserveTokens` that grows with the served context window. In pi, `reserveTokens` is headroom it keeps free for the response, not a conversation budget, so a reserve that scales with the window makes the compaction trigger stay at 15,000 tokens whatever the window is. On my 128K session pi compacted after about 15,000 tokens of a 131,072-token window, then kept compacting every turn or two after that. The 116K of the window I had paid for was never used. pi's own reference says the reserve is fixed headroom and does not scale: Auto-compaction triggers when: contextTokens > contextWindow - reserveTokens By default, `reserveTokens` is 16384 tokens (configurable in ~/.pi/agent/settings.json …). This leaves room for the LLM's response. docs/compaction.md of pi 1.1.0, and pi 1.1.0's default in its own settings-manager is 16384 for every model. Strata writes instead (strata_cli/launch/harness.py, `pi_settings`, line 134): "reserveTokens": max(1024, t.context - COMPACT_AT) # COMPACT_AT = 15000, harness.py:24 Values `strata connect pi` prints for the same model at each served window (measured on my machine): --context 32k reserveTokens 17,768 pi compacts above 15,000 45.8% of the window used --context 64k reserveTokens 50,536 pi compacts above 15,000 22.9% of the window used --context 128k reserveTokens 116,072 pi compacts above 15,000 11.4% of the window used Expected: at 128K the app should keep most of the window for the conversation and compact when the window is close to full, the way pi's own default does at every window size. Actual: it compacts at 15,000 tokens, and nothing on screen says a line at 15,000 was chosen: the limits text for pi (harness.py:182) says the same "about 15K tokens before it summarises" at 128K as at 32K, so the config read back to me looked reasonable. The 32K case is the only one that was ever measured: harness.py's own docstring (line 3) says the eight configs come from configs "tested for real against a Strata server at 32K context". So this is the tested 32K constant applied unchanged to windows nobody checked, written in the one app's unit where it becomes a meaningless number. The presence of the key is right and should stay: for other apps the app's own default is broken for a local model (without `limit.input` OpenCode never compacts, and Claude Code without `CLAUDE_CODE_MAX_CONTEXT_TOKENS` "never compacts, or compacts on every turn"). It is the value at non-32K windows that is wrong. ### Smallest steps or command that reproduce it No GPU and no download needed to see the value written: strata connect pi --context 128k --output json # "contextWindow": 131072 … "reserveTokens": 116072 strata connect pi --context 64k --output json # "contextWindow": 65536 … "reserveTokens": 50536 strata connect pi # my saved preset, 32K, prints 17768 To see the behaviour in pi itself: `strata connect pi --write --yes`, start a session and watch the first `/compact`-style summary land near 15,000 tokens of a 131,072-token window rather than near the end. Workaround I used: after `strata connect pi` wrote the file I set `compaction.reserveTokens` by hand back to a fixed headroom and left everything else as written. ### Reproduction status Reproduced locally for the values `strata connect` prints and for the early compaction in my 128K session. pi's trigger formula and its 16384 default are read from pi 1.1.0's own docs and settings-manager on my machine, not re-derived from a Strata run. I did not test a 64K pi session and did not measure any engine-side cost of the extra compactions. ### Strata version strata 0.2.2 (build 0.1.47) — from `strata --version`. pi 1.1.0 (`npm install -g @earendil-works/pi-coding-agent` today); `strata connect pi --check` reports this config was tested with pi 0.74.2, so the pi version I read the semantics from is not the one the config was tested against.
Author
Owner

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

Fixed in 0.2.5 (see #3850): the compaction point scales with the window, so a 128K session no longer compacts at 15,000 tokens. Run strata connect pi again after updating.

<!-- gh-comment-id:6423176815 --> @Niko1221 commented on GitHub (Oct 26, 2026): Fixed in 0.2.5 (see #3850): the compaction point scales with the window, so a 128K session no longer compacts at 15,000 tokens. Run strata connect pi again after updating.
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#1578
No description provided.