mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3928] [Engine] Stop during a long prompt read loses the read prefix; the next message re-reads 375K tokens (22 min) #1680
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#1680
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 24, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3928
Area
[Engine] (speed, kernels, models, the server and API)
Desktop app, Terminal or source?
Desktop app (Windows, Linux or Mac)
What happened
A long agent chat on Strata 0.2.3 / engine 0.1.48 (Swift 1.5 IQ3_XXS, 512K context,
--kv int8) reached 420,729 tokens. The auto-compaction threshold for this window is 419,430 tokens (see Root cause). The next prompt was 375,788 tokens — 44,941 tokens shorter — and only 6,165 tokens matched the cached prefix.While the engine was reading that prompt, I pressed Stop at 506 s / 148,480 of 369,623 tokens. The next message was 375,844 tokens, and the engine reported:
The chat showed "thinking" for 21 m 57 s before the first token. The answer itself took 12.5 s. It was not a hang:
reading the promptadvanced by 1,024 tokens about every 3.5 s (... 375,791 of 375,844 tokens, 1317 s so far).The same cold read happens without Stop when a subagent request takes the engine slot. A 12,465-token child request was served (
6,127 reused + 6,338 read), then the parent's next turn was 385,386 tokens and re-read 379,259 tokens in 1,326,029 ms (22 m 06 s), with only 6,127 reused. The parent's 6,406 MiB snapshot was refused by the 3,840 MiB conversation cache.So the user-visible symptom is "after I stop it, the next message thinks for 20+ minutes". The engine is not stuck; it is re-reading the whole prompt from token 0.
Smallest steps or command that reproduce it
--max-context 524288,--kv int8), e.g. Swift 1.5 IQ3_XXS.0 reused + 375844 read in 1317159 ms; the UI shows "thinking" for about 22 minutes.Without Stop: run a subagent request in the same long chat, then continue the parent. The parent's next turn re-reads 379,259 tokens (22 m 06 s).
Reproduction status
Reproduced locally
Strata version
Strata 0.2.3, engine 0.1.48, Windows 11 Pro 26H2 build 26300. Code references are to the public repository
main@8183c6b(2026-10-24); the installed engine 0.1.48 was built earlier, so line numbers may shift, but the log strings match.Graphics card, memory and system
NVIDIA GeForce RTX 3080 Ti Laptop GPU, 16 GB VRAM · 64 GB RAM · Windows 11 Pro 26H2, build 26300.
Model, size and settings
Swift 1.5 IQ3_XXS · 512K context (
--max-context 524288) ·--kv int8·--vram-reserve-mib 1536· conversation cache auto-sized to 3,840 MiB for up to 4 parked conversations.Logs
Root cause and suggested fix
1. Auto-compaction rewrites the early history, so the old prefix no longer matches.
localOutputBudget(524288)is 32,768 andcompactionHeadroom(524288, 32768)is 61,440, so the host's threshold is:The request at 420,729 crossed it. The next prompt is 375,788, 44,941 tokens shorter; the summary replaced the early messages. Only the system-prompt prefix (6,165 tokens) still matches. This is the same post-compaction re-read pattern as #3701 (there: 154,601 tokens re-read on 2× V100; here: 369,623 tokens on a 16 GB laptop).
2. A Stop during the read does not keep the read prefix, and the next request clears the checkpoints.
The read loop sets
pp_exact = falsebefore a batched/pipelined part (src/program/generate.cppL14084) and sets it true only after the part completes. The #1620 retention branch requirespp_exact(generate.cppL15232–L15248), so a cancel that lands inside a part does not keep the session. The log contains nocancelled request keeps its conversationline (0 occurrences).The next request then starts at
resume == 0;generate.cppL12951–L12959 callschecks.clear(), dropping the 6 checkpoints the cancelled read had banked. That is why the next request reports0 reused, not 6,165. The checkpoints are described as "still good" in the cancel path comment (L15233–L15234), but they are discarded on the next request.This is different from #1620 (closed; its fix only applies to a cancel between two windows, where
pp_exactis true) and from #3675 (open; there the cancel does not stop the read at all). Here the read does stop, but its progress is thrown away.3. The parking fallback cannot save the conversation because the snapshot is larger than the cache.
The 375K-token conversation snapshot is 6,925 MiB; the auto-sized cache is 3,840 MiB for up to 4 parked conversations.
make_room()returns false andgenerate.cppL9560–L9563 printsskip parkingand continues with a full read. This is not an edge case on a 64 GB machine with a 512K window: a 375K-token chat needs about 6.9 GB of KV, nearly twice the default budget.4. A subagent request causes the same cold read without Stop.
The 12,465-token child request takes the engine slot. The parent's 6,406 MiB snapshot cannot be parked, so the parent's next turn re-reads 379,259 tokens (22 m 06 s). This is the normal coding-assistant workflow, not an unusual action.
5. The UI calls all of this "thinking".
The host polls
/metricsand treats the advancingprompt_readas activity, so the watchdog gives the engine up to 30 minutes (engineGraceMs). The turn is not killed, but the chat only shows "thinking" with no prefill progress or ETA. The engine knows the numbers; the UI does not show them.Suggested fix, in order of impact:
checkson the nextresume == 0when the new prompt shares a prefix; try the nearest checkpoint and re-read only the tail.Duplicate search
Searched open and closed issues and PRs for
conversation cache,prefill cancel,reading the prompt,compact cache,conversation-cache-mib,keeps its conversation,skip parking,cold prefill,cancel prompt read,stop re-read,compaction re-read,mid-read, andcancelled request.Closest reports:
pp_exacttrue), not a cancel inside a read part.No existing report covers the mid-read cancel + checkpoint loss + oversized snapshot combination on 0.2.3 / 0.1.48.
@github-actions[bot] commented on GitHub (Oct 24, 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 24, 2026):
Thanks, this follows the format now.
@xvcezrqpbxtpzblrt commented on GitHub (Oct 31, 2026):
Checked again on the current engine, 0.1.54 (31 Oct 2026). A stop inside a prompt read still throws away the progress that read had already made — same shape as this report, at a much smaller size. From this machine's
strata servelog (%LOCALAPPDATA%\Strata\install\strata-iq3_s.log; engine started 2026-10-30 22:25:21 fromcomponents\engine\0.1.54-windows-x86_64-cuda-cuda13,--max-context 393216 --kv int8 --spec 4 --rope-scaling yarn --rope-scale 1.5; 297 prompt-read lines):What the three lines say:
12328 tokens = 6162 reused), read all 6,166 again, 9,943 ms a second time. The work of a read that got almost to the end is not turned into a checkpoint that the next request could pick up.Limits on this data point, stated so it is not over-read:
compactandsummarboth 0 matches over 297 prompt-read lines): compaction never fired here, because the threshold for a 393,216 window sits above every prompt this run reached (largest 265,093). It therefore says nothing about #3998's five-cycle pattern and should not be read as evidence for or against that issue.The suggested fix stands unchanged: when a read part is cancelled mid-way, keep the checkpoints made up to that point and resume from the nearest one instead of reading the same segment again.
@Niko1221 commented on GitHub (Oct 31, 2026):
On the current engine we tested a smaller case: a Stop in the middle of a 36K-token read, then the same request again. The second request reused 21,725 of 36,437 tokens, so the checkpoints already saved are kept and only the part after the last one is read again. That is better than the 0.1.48 behaviour you saw (nothing reused). We have not tested your 375K case, where the conversation does not fit the cache and cannot be parked. We have not changed anything for this yet.