mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4921] [Engine] dsv41: reuse a kept conversation past a changed span (KV splice), opt-in #2261
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#2261
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 @PhialsBasement on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4921
Area
[Engine] (speed, kernels, models, the server and API)
What do you want to do?
Coding agents put per-session text inside the system prompt, ahead of tens of thousands of tokens that are the same in every session. OpenCode writes the working directory, the date, the git status and the project's instruction files near the top, and synced skills carry a random folder id in their paths. The conversation cache only reuses a prompt's shared start, so every new session (another folder, the next day) reads the whole prompt again.
Measured on my machine (environment below), with OpenCode 1.18.34 and its 6 MCP servers (about 37.5K tokens before the first user message):
I want the engine to reuse a kept conversation past a changed span instead of reading the whole prompt. This matters for coding agents using OpenCode with MCP servers: it saves read time on every new session.
What do you do today instead?
env_to_usermoves only the<env>block. Project instruction files and skill paths still differ, so the read starts over at the first of them.Proposed behavior
When a prompt does not continue the conversation in the model, the engine aligns it with the state in the model and every kept conversation, using token runs of 32 found wherever they sit, so a prompt the engine reordered last turn still matches. It takes the one it can reuse most:
ckv,ik) move down, every window ring rotates, and the cut is recorded as a RoPE gap (rope_off), added at eachFinish.possite. The cut table is saved with the slot as an optional trailer (DS4CUTS1); an engine without it refuses such a slot and reads the prompt again.vocab.json), and cuts widen to the state's group size (the compress ratio, 2 here), so the model sees complete lines. Without this, a cut mid-line left text such asaccuracyddcb1_a438...in the prompt, and the model said its environment info looked garbled.Proposed as opt-in (
STRATA_DS4_REORDER=1), default off.Tradeoffs
Evidence so far
All on Strata 0.1.55 (
c62d5e3a), HIP build ofstrata-dsv41from source (system ROCm 7.2.4, gfx1201), RX 9070 XT 16 GB, Ryzen 7 5800X3D, 64 GB DDR4, CachyOS kernel 7.3.0-4, deepseek-v4.1-flash-ist-das-1.75bpw, 1M context./v1/chat/completions(30 tools, a 19.4K-token system prompt, only the<env>lines differ): the first read 19,428 tokens in 77 to 79 s; the second reused 19,355 and read 72 in about 10 s, and answered with the second session's folder, which only appears in the moved lines.Not run
CUDA, SYCL and Metal builds; Strata's C++ test suite; a quality benchmark with the option on and off.
Related, client side
OpenCode drops
reasoning_contentfrom earlier turns of a custom OpenAI-compatible model unless the model sets"interleaved": { "field": "reasoning_content" }, while V4.1's template keeps earlier reasoning when tools are present. Without that setting, each follow-up cuts the previous reply's reasoning out of the cache. This could be worth a line in the OpenCode connection docs or instrata connect opencode.The branch is ready to split into a PR once the scope is agreed.
@github-actions[bot] commented on GitHub (Nov 1, 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 (Nov 1, 2026):
Thanks, this follows the format now.
@PhialsBasement commented on GitHub (Nov 2, 2026):
The implementation is on a branch for anyone who wants to try it: https://github.com/PhialsBasement/Strata/tree/dsv41-kv-splice
Note: on that branch the feature is on by default (
STRATA_DS4_REORDER=0turns it off); a PR would flip it to opt-in as proposed above. Built and tested with HIP on gfx1201 only.Build (HIP example):