agy-cli 0.1.96: a resumed session runs in its own folder again, so agy's cache still hits

@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.
This commit is contained in:
yetone
2026-11-19 01:14:23 +08:00
parent 63c2ff93f4
commit 62645eceb7
6 changed files with 91 additions and 21 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-agy-cli-auth",
"version": "0.1.95",
"version": "0.1.96",
"description": "Magpie/OpenCode model provider that connects your local agy CLI through the Agent Client Protocol (agy acp), so Antigravity subscription models run through the real CLI",
"type": "module",
"main": "./opencode.mjs",