mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4744] [Other] compaction policy: two fixed ratios decide when it runs, and the checkpoint is capped by the same headroom it protects (2,867 tokens at a 32K window) with truncation as a hard failure #2177
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2177
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @xvcezrqpbxtpzblrt on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4744
2026-11-06 更新:v0.2.10 / v0.2.11 发布说明均未点名本 issue。便于处理起见,本 issue 主要跟踪:触发线与保留率固定、检查点上限与头部保护同源、截断即失败。图片卸载与字符预算两项如需单独排队,请您指出。
Area
[Other] (the agent runtime configuration Strata ships; the policy itself lives in the bundled compaction plugin)
Desktop app, Terminal or source?
Desktop app (Windows), with the arithmetic read from
apps/host/server/agent/profile.mjsandapps/host/server/agent/preset.mjsat tagv0.2.8, and from the compaction plugin installed with the app.What happened
Long sessions lose their thread faster than the numbers should allow. Compaction today is driven by two fixed fractions and one fixed band, and the size of the replacement summary is tied to the same number that protects the window — so a condensation is forced to be tiny, and if it is not tiny enough it is rejected. The retention rule is recency only, and every pass re-summarises the checkpoint from the previous pass, with nothing bounding the drift.
The chain, with numbers that follow from the shipped code (not measurements):
harness/node_modules/@deepseek-ai/dsh-compaction-basic/lib/index.js:839,agent/pre-step), and the threshold isfloor(min(contextWindow * thresholdRatio, contextWindow - reservedCompletionTokens - headroomTokens))(:130-132) withDEFAULT_THRESHOLD_RATIO = .8(:15).headroomTokens, per model, fromapps/host/server/agent/profile.mjs:151-153:max(512, min(65536, floor((context - outputBudget) * 0.125))), pushed atprofile.mjs:214,:244,:286. It never setsretainRatio,retainTokensormaxTokens.localOutputBudget = max(4096, min(32768, floor(context * 0.3)))(profile.mjs:137-143).dsh-compaction-basic/.../index.js:64and:71— "maxTokens … from headroomTokens"). The number that protects the window is also the ceiling on the summary that has to replace the older history.Computed for the three windows a local user actually picks (from the two formulas above):
dsh-compaction-basic/.../index.js:363); after one retry the turn continues uncompacted with a warning, so a 32K session that needs to shed 16K tokens of history can end up shedding nothing.DEFAULT_RETAIN_RATIO = .16(:17),retainTokens = floor((contextWindow - reservedCompletionTokens) * retainRatio)(:133), and the tail is accumulated newest-first (:416-422). Nothing scores importance, and nothing deduplicates: repeated tool output that never changed is kept, while an early decision the whole task depends on is dropped.:415,firstIdx = 1), so the previous checkpoint sits inside the next range and is merged only because the prompt asks the model to fold it in. Lossy re-summarisation of a lossy summary is unbounded.thresholdChars: 8192, headChars: 4096, tailChars: 1024(apps/host/server/agent/preset.mjs:77) and runs from the pressure path, not proactively. Character budgets misprice CJK and code alike, and there is no dedup of identical repeated output.harness/node_modules/@deepseek-ai/dsh-compaction-image-offload) but Strata's compaction group registers onlycompaction-basicandtool-result-pruner(preset.mjs:73-77), so images stay inline in the surface and are replayed into the summariser request; the app keeps at most three picture slots per request from the newest side (apps/host/src/lib/chat-photos.ts:20).None of this is the re-read cost already tracked under #3998, #3928, #2228 and (closed) #3701 — this report is about the quality and size policy of the condensation, and it is a separate axis: an engine-side fix to the conversation cache would not change any of the numbers above.
Smallest steps or command that reproduce it
localOutputBudgetandcompactionHeadroomare two pure functions inapps/host/server/agent/profile.mjs:137-143and:151-153; the threshold and retention formulas are atdsh-compaction-basic/lib/index.js:130-133in the installed 0.2.8. The table above is those functions evaluated at 32,768 / 65,536 / 393,216.Reproduction status
Mixed, and stated per part: the arithmetic is confirmed (two functions in the repo, three constants in the installed plugin, evaluated above; the 65,536 case is already asserted by the repo's own test
apps/host/tests/agent-context.test.mjs:43-51, which pins 40,142). The behavioural consequence — detail lost and then re-summarised — is reported by the person at the keyboard over long local sessions and is consistent with the numbers; it was not measured with a scripted A/B. The local engine log on this machine contains no compaction at all (the largest prompt seen, 206,881, is below the 314,572 threshold for a 393,216 window), so no log evidence is offered here — see #3998 for the re-read cost side.Strata version
Strata 0.2.8 — app
0.2.8, Control and engine0.1.54, agent componentdeepseek-harness0.2.1-alpha.3(the compaction plugin is bundled inside that component; the line numbers quoted for it are from the installed 0.2.8 copy, since the plugin source is not in this repository).Graphics card, memory and system
NVIDIA GeForce RTX 3080 Ti Laptop GPU 16 GB - 64 GB RAM - Windows 11 Pro build 26300
Model, size and settings
Qwen3.8-Flash-Next IQ3_S,
--max-context 393216, rope yarn ×1.5, KV int8, MTP drafting on. The formulas above are model-independent; the model only setscontextWindowandmaxTokens.Logs
C:\Users\123\AppData\Local\Strata\install\strata-iq3_s.log— 194 prompt-read lines, and notably zero compaction lines: the largest prompt in this log is 206,881 tokens, below the 314,572-token threshold this window computes, so compaction never fired here. This log corroborates the re-read pattern (#3998 family), not this issue; it is offered so that nobody reads it as evidence of compaction on this machine.Duplicate search
Searched open and closed issues for
compaction,compact,summariz/summaris,context full,keep recent,prune,checkpoint,context window:compactionHeadroominprofile.mjs:151-153. Different problem (the failure to compact at all), same knob.No issue covers: the checkpoint cap being tied to the headroom, truncation as a hard failure, the fixed .16 recency-only retention with no importance or dedup, unbounded re-summarisation of previous checkpoints, character-based reactive tool pruning, or the image-offload plugin not being registered.
Suggested fix (not tested)
max(1024, min(8192, replacedSpan * k))for somek) instead of inheritingheadroomTokens, and size the headroom from what a checkpoint of that budget actually costs. The 5.7:1 collapse in the table is a consequence of one constant doing two jobs.retainRatio/retainTokensto Strata the wayheadroomTokensis exposed, and give a cheap importance signal (nodes named by a later message, file paths that were edited, decisions the plan repeats) instead of pure recency. Dedup identical tool output.preset.mjs:73-77) or delete it from the bundle, so a reader is not told the harness handles pictures when the app never calls it.@github-actions[bot] commented on GitHub (Oct 30, 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:
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
@github-actions[bot] commented on GitHub (Oct 30, 2026):
Thanks, this follows the format now.
@Memosis commented on GitHub (Nov 1, 2026):
Adding a data point from a Windows desktop user, plus a related request.
Setup: Strata desktop app (Windows), context set to 200K.
Observation: automatic compaction starts at about 75% of the window. This matches the formulas in this issue (
compactionHeadroom/localOutputBudgetinprofile.mjs, threshold in the plugin). Evaluated at 200,000:So at 200K the headroom term, not the 0.8 ratio, decides the trigger point.
Request: besides exposing
retainRatio/retainTokensas suggested above, please also expose the trigger point itself as a user-facing setting (for example a percentage, orheadroomTokens/ reply reserve), in the Models screen or in a config file. I could not find any option for this in the README, docs, release notes or other issues. For users who rely on large contexts, compacting at about 73% means summarising and losing detail while tens of thousands of tokens are still free.I understand a higher trigger has to leave room for the reply reserve and the checkpoint, so a setting could be clamped to something like
context − reply reserve − checkpoint cap. It would also help if the default stayed as it is for small windows (32K/64K), where the current headroom logic matters most.Happy to test a build if that helps.