@chet030714 on X: Hermes through agy-cli started near 70% cache hits and
fell all day. agy's prompt cache follows the folder its process runs in.
Every agy the bridge started had a new mkdtemp folder, so a session
resumed after the 10-minute idle reclaim, an LRU eviction or a restart
replayed its whole history uncached, and the longer a conversation got,
the more each resume cost.
Measured with real agy 1.5.10 over ACP in a sandbox HOME (one session,
~24K tokens a turn): every turn in one process hit (cachedReadTokens
19,682 to 197,710). A resume in the same folder: 213,520 cached. In
another folder: 0 cached, 219,198 uncached. Only the process's folder
counts, not session/resume's cwd. The same folder after 13 minutes
idle, or removed and made again at the same path, still hits.
Now a parked session records its workspace, and a resume starts agy in
that folder (made again if it was removed), never in a spare's. Only a
magpie-agy-bridge-XXXXXX folder directly in the temp folder is taken
from the state file. A stopped agy leaves its folder when another
already runs there, and a resume waits for a removal in progress.
Run (at 63c2ff93 + this diff):
- mica, HOME=$(mktemp -d): packages/agy-cli `bun test`: 41 pass, 0 fail.
- The new test (usage-settlement.mjs, LRU resume runs in the session's
folder) on the old index.mjs, by hand: fails.
- The real bridge, index.mjs loaded with real agy in a sandbox HOME, two
turns with the process reclaimed between them (AGY_BRIDGE_IDLE_MS=5000):
old code, resumed turn 0 of 32,127 cached; this change, 29,681 of
32,018 cached.
Not tried: Windows and Linux with real agy. A resume from a park entry
written before this version still starts in a new folder, once.