[GH-ISSUE #3891] [Engine] Automatic disk-backed conversation cache with size cap and auto-eviction, for subagent workloads on low-RAM machines #1663

Open
opened 2026-11-04 01:53:01 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @phly95 on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3891

Area

[Engine]

What do you want to do?

Keep conversations alive across turns when several of them alternate on a server that handles one request at a time, without the client calling any API and without the box having RAM to spare for parked snapshots. In short: an opt-in, automatic disk tier under the conversation cache that is configured in the run config and manages itself.

Who needs it: people running agent clients with subagents (e.g. Claude Code with 4 subagents sharing one server) on machines with limited RAM, where one concurrent request is all the memory allows.

Requested behavior

  • Automatic. When the active conversation changes, the engine parks the outgoing one and, when a conversation returns, restores it, with no /slots/0?action=save|restore calls from the client.
  • Disk as a tier, not only RAM. Park to a directory on SSD/NVMe; the RAM budget can be small or zero.
  • Self-managing size. Config options along the lines of a directory, a total size cap (MiB), and optionally a maximum entry age or entry count. Least-recently-used entries are evicted when the cap is reached; stale or orphaned files are cleaned up at start and stop. No manual cleanup.
  • Cheap switches. Restoring from disk should be much cheaper than re-reading a long prompt (see the numbers below).
  • Opt-in and off by default, so nothing changes for existing setups.

Why: what the docs say happens today

Reading docs/DETAILS.md and docs/BATCHING.md (0.2.3.1):

  • Without "parallel": N Strata serves one request at a time; others wait in the queue.
  • The engine holds one live session plus up to 6 checkpoints in RAM that are shared by all conversations and rotate by least recent use. The oldest (the system-prompt root) is kept for good.
  • "one conversation cached at a time (switching between two chats re-reads the other one unless the opt-in cache above is enabled, or each conversation keeps its own batch slot)".
  • So with several subagents taking turns, each one probably re-reads its own conversation from the shared system-prompt root, unless one of its checkpoints survived. (This is my reading of the docs; I have not measured the re-read cost on my setup.)

The existing options each need something these machines lack:

  • --conversation-cache-mib parks in RAM only. The docs themselves describe stalls from paging when the budget is large (#2049).
  • "parallel": N needs VRAM per slot and a 262144 context is already tight.
  • Disk sessions (--slot-save-path, POST /slots/0?action=save|restore) work, but only through explicit calls: single slot 0, no erase action (the caller manages the files), they run between requests while the queue is held, and they return 501 with parallel requests. A client such as Claude Code will never call them, so they cannot help here without a wrapper in front of the server.

For scale, the docs measure a 63,025-token conversation on a 12 GB card with NVMe: a 1.20 GB file, save 0.65 s, restore 1.05 s, against 25.5 s for the cold first turn. Single runs, different hardware and model than mine, but it shows why a disk tier is attractive when RAM is short.

My setup

Linux, AMD/HIP (container), about 62 GiB RAM with about 8 GiB available while the model runs, container capped at 57 GiB; Qwen3.8-Flash-Next IQ3_S, --max-context 262144 --kv int8, no parallel, no conversation-cache budget. Clients: Claude Code and similar agents with several subagents.

  • #3485: measurements for a disk tier under the conversation cache (the same direction; this issue asks for the feature to be automatic, self-managing and configurable, aimed at the low-RAM subagent case)
  • #1962: share identical KV prefix blocks across concurrent conversations
  • #342: subagent turns evicting the parent conversation's cache (closed)
  • #3744: session files refuse multi-GPU layer-split runs

What do you do today instead?

Nothing automatic. The options are accepting the re-reads, running fewer concurrent subagents, or putting a client-side wrapper in front of Strata that drives the slot API, which means identifying conversations from the outside and blocking the queue while it saves and restores.

Originally created by @phly95 on GitHub (Oct 23, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3891 ### Area [Engine] ## What do you want to do? Keep conversations alive across turns when several of them alternate on a server that handles one request at a time, **without the client calling any API and without the box having RAM to spare for parked snapshots.** In short: an opt-in, automatic disk tier under the conversation cache that is configured in the run config and manages itself. Who needs it: people running agent clients with subagents (e.g. Claude Code with 4 subagents sharing one server) on machines with limited RAM, where one concurrent request is all the memory allows. ### Requested behavior - **Automatic.** When the active conversation changes, the engine parks the outgoing one and, when a conversation returns, restores it, with no `/slots/0?action=save|restore` calls from the client. - **Disk as a tier, not only RAM.** Park to a directory on SSD/NVMe; the RAM budget can be small or zero. - **Self-managing size.** Config options along the lines of a directory, a total size cap (MiB), and optionally a maximum entry age or entry count. Least-recently-used entries are evicted when the cap is reached; stale or orphaned files are cleaned up at start and stop. No manual cleanup. - **Cheap switches.** Restoring from disk should be much cheaper than re-reading a long prompt (see the numbers below). - Opt-in and off by default, so nothing changes for existing setups. ### Why: what the docs say happens today Reading `docs/DETAILS.md` and `docs/BATCHING.md` (0.2.3.1): - Without `"parallel": N` Strata serves one request at a time; others wait in the queue. - The engine holds one live session plus up to 6 checkpoints in RAM that are shared by all conversations and rotate by least recent use. The oldest (the system-prompt root) is kept for good. - "one conversation cached at a time (switching between two chats re-reads the other one unless the opt-in cache above is enabled, or each conversation keeps its own batch slot)". - So with several subagents taking turns, each one probably re-reads its own conversation from the shared system-prompt root, unless one of its checkpoints survived. (This is my reading of the docs; I have not measured the re-read cost on my setup.) The existing options each need something these machines lack: - `--conversation-cache-mib` parks in RAM only. The docs themselves describe stalls from paging when the budget is large (#2049). - `"parallel": N` needs VRAM per slot and a 262144 context is already tight. - Disk sessions (`--slot-save-path`, `POST /slots/0?action=save|restore`) work, but only through explicit calls: single slot 0, no erase action (the caller manages the files), they run between requests while the queue is held, and they return 501 with parallel requests. A client such as Claude Code will never call them, so they cannot help here without a wrapper in front of the server. For scale, the docs measure a 63,025-token conversation on a 12 GB card with NVMe: a 1.20 GB file, save 0.65 s, restore 1.05 s, against 25.5 s for the cold first turn. Single runs, different hardware and model than mine, but it shows why a disk tier is attractive when RAM is short. ### My setup Linux, AMD/HIP (container), about 62 GiB RAM with about 8 GiB available while the model runs, container capped at 57 GiB; Qwen3.8-Flash-Next IQ3_S, `--max-context 262144 --kv int8`, no `parallel`, no conversation-cache budget. Clients: Claude Code and similar agents with several subagents. ### Related - #3485: measurements for a disk tier under the conversation cache (the same direction; this issue asks for the feature to be automatic, self-managing and configurable, aimed at the low-RAM subagent case) - #1962: share identical KV prefix blocks across concurrent conversations - #342: subagent turns evicting the parent conversation's cache (closed) - #3744: session files refuse multi-GPU layer-split runs ## What do you do today instead? Nothing automatic. The options are accepting the re-reads, running fewer concurrent subagents, or putting a client-side wrapper in front of Strata that drives the slot API, which means identifying conversations from the outside and blocking the queue while it saves and restores.
Author
Owner

@heitor-lassarote commented on GitHub (Oct 26, 2026):

I second this. My setup has 32 GB RAM and a feature like this would help us who have less RAM.

<!-- gh-comment-id:6416017083 --> @heitor-lassarote commented on GitHub (Oct 26, 2026): I second this. My setup has 32 GB RAM and a feature like this would help us who have less RAM.
Author
Owner

@lyrakat commented on GitHub (Oct 31, 2026):

I'd find this useful too. I run an agent on a single 16 GB GPU with 64 GB of RAM. With the model loaded and a long context, most of the RAM is already in use, so parking a conversation is usually skipped. When a short side request comes in between turns, such as a title or a summary, the next turn reads the whole conversation again. At around 200K tokens that takes about three minutes.

An automatic disk tier like this would help me and others whose RAM fills up the same way. Thanks for considering it.

<!-- gh-comment-id:6542162338 --> @lyrakat commented on GitHub (Oct 31, 2026): I'd find this useful too. I run an agent on a single 16 GB GPU with 64 GB of RAM. With the model loaded and a long context, most of the RAM is already in use, so parking a conversation is usually skipped. When a short side request comes in between turns, such as a title or a summary, the next turn reads the whole conversation again. At around 200K tokens that takes about three minutes. An automatic disk tier like this would help me and others whose RAM fills up the same way. Thanks for considering it.
Author
Owner

@steve8697 commented on GitHub (Nov 4, 2026):

A data point from a Windows desktop install, and a request to consider the oMLX placement model rather than only whole-conversation files.

Setup: one RTX 5090, about 94 GB of RAM, engine 0.1.56, one request at a time. The NVFP4 expert arena stays pinned at about 63 GB, so the conversation cache holds roughly two long snapshots. An agent alternates a main chat of about 170k–220k tokens with a second chat that edits its skills. When another snapshot does not fit, the oldest parked conversation is dropped, and coming back re-reads tens of thousands of tokens, about 10–30 seconds of prefill. --slot-save-path is already enabled, but the client never calls save or restore. A process outside the engine also cannot save the evicted snapshot: that copy has already been freed when the eviction line is logged, and a restore has to happen before the next prefill.

The behavior described in this issue is the missing piece: on a switch, write the outgoing conversation to a bounded SSD directory and read it back when that conversation returns, with no client API call.

oMLX (https://github.com/jundot/omlx) is a finer version of the same idea on Apple Silicon. KV is stored in blocks. Hot blocks stay in RAM. When RAM is full, blocks spill to SSD instead of being discarded, and a later request restores the matching prefix from disk, including after a restart. Copy-on-write keeps a shared prefix once until the conversations diverge. That last part matters for the skill-edit case. A single session file of the whole conversation stops matching when the edit changes the start of the prompt, so the tail is prefilled again. Block reuse can keep the parts that did not change.

Would you try that model for this disk tier, not only a whole-snapshot spill along the lines of the closed #1480 and the open #1937? I can retest on this machine if an opt-in flag reaches a Windows CUDA build.

<!-- gh-comment-id:6621353095 --> @steve8697 commented on GitHub (Nov 4, 2026): A data point from a Windows desktop install, and a request to consider the oMLX placement model rather than only whole-conversation files. Setup: one RTX 5090, about 94 GB of RAM, engine 0.1.56, one request at a time. The NVFP4 expert arena stays pinned at about 63 GB, so the conversation cache holds roughly two long snapshots. An agent alternates a main chat of about 170k–220k tokens with a second chat that edits its skills. When another snapshot does not fit, the oldest parked conversation is dropped, and coming back re-reads tens of thousands of tokens, about 10–30 seconds of prefill. `--slot-save-path` is already enabled, but the client never calls save or restore. A process outside the engine also cannot save the evicted snapshot: that copy has already been freed when the eviction line is logged, and a restore has to happen before the next prefill. The behavior described in this issue is the missing piece: on a switch, write the outgoing conversation to a bounded SSD directory and read it back when that conversation returns, with no client API call. oMLX (https://github.com/jundot/omlx) is a finer version of the same idea on Apple Silicon. KV is stored in blocks. Hot blocks stay in RAM. When RAM is full, blocks spill to SSD instead of being discarded, and a later request restores the matching prefix from disk, including after a restart. Copy-on-write keeps a shared prefix once until the conversations diverge. That last part matters for the skill-edit case. A single session file of the whole conversation stops matching when the edit changes the start of the prompt, so the tail is prefilled again. Block reuse can keep the parts that did not change. Would you try that model for this disk tier, not only a whole-snapshot spill along the lines of the closed #1480 and the open #1937? I can retest on this machine if an opt-in flag reaches a Windows CUDA build.
Author
Owner

@shoucandanghehe commented on GitHub (Nov 5, 2026):

I have a local engine-side disk-cache implementation, but #3341, #4226 and #5211 already cover automatic persistence, so I do not want to open another competing disk-tier PR.

There are three separable capabilities I could contribute to the selected design:

  • Idle batch-slot SAVE/RESTORE, with the slot claimed before the command and bound to the process that owned that claim. This is distinct from saving by client-session identity in #4409; current main explicitly refuses batch session-file operations.
  • RAM-first reuse with asynchronous persistence: do not read disk when a compatible live/slot/parked state already satisfies the checkpoint boundary; retain the captured sources until the writer finishes, expose write failures, and join on explicit FLUSH/shutdown.
  • Physical disk-block sharing across conversation manifests: immutable full K/V chunks are stored once, while tails and mutable execution state remain private. Publication, quota accounting and last-owner reclamation belong with this feature; it is not approximate state compression or a claim that arbitrary suffixes can be reused after a prefix edit.

Which of these are in scope, and which existing branch should they target? I would keep them independently reviewable instead of bundling them into #1962's RAM-sharing PR. These are descriptions of inspected local code, not current-main runtime results; no new performance, durability or backend-compatibility claim is being made.

<!-- gh-comment-id:6660044042 --> @shoucandanghehe commented on GitHub (Nov 5, 2026): I have a local engine-side disk-cache implementation, but #3341, #4226 and #5211 already cover automatic persistence, so I do not want to open another competing disk-tier PR. There are three separable capabilities I could contribute to the selected design: - **Idle batch-slot SAVE/RESTORE**, with the slot claimed before the command and bound to the process that owned that claim. This is distinct from saving by client-session identity in #4409; current main explicitly refuses batch session-file operations. - **RAM-first reuse with asynchronous persistence**: do not read disk when a compatible live/slot/parked state already satisfies the checkpoint boundary; retain the captured sources until the writer finishes, expose write failures, and join on explicit FLUSH/shutdown. - **Physical disk-block sharing** across conversation manifests: immutable full K/V chunks are stored once, while tails and mutable execution state remain private. Publication, quota accounting and last-owner reclamation belong with this feature; it is not approximate state compression or a claim that arbitrary suffixes can be reused after a prefix edit. Which of these are in scope, and which existing branch should they target? I would keep them independently reviewable instead of bundling them into #1962's RAM-sharing PR. These are descriptions of inspected local code, not current-main runtime results; no new performance, durability or backend-compatibility claim is being made.
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#1663
No description provided.