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:
@@ -63,7 +63,8 @@ agy 连接 `--ide-mcp-port` 时会运行 `nc 127.0.0.1 <端口>`。插件在 agy
|
||||
- **工具调用**:支持并行和连续调用。运行超过 150 秒的工具会先收到 "still running" 的
|
||||
占位响应,真正的结果送达后继续同一轮对话,每个调用只在客户端执行一次。
|
||||
- **会话续接**:每轮结束后记录会话。重启 Magpie 或插件后,只要历史和指令的哈希一致,
|
||||
就用 `session/resume` 接上上下文。状态文件只存会话 ID 与哈希,不存消息原文。
|
||||
就用 `session/resume` 接上上下文。agy 的提示缓存跟着它运行的目录走,所以接上的会话
|
||||
回到原来的临时目录里运行,缓存照样命中。状态文件只存会话 ID、哈希和这个目录,不存消息原文。
|
||||
- **隔离运行**:不读取你的全局 MCP 配置。每个 agy 进程使用临时 agent。agy 为它自己的
|
||||
工具发起的权限请求(shell、写文件、浏览器等)一律拒绝;客户端工具经桥接的 `ide-tools`
|
||||
调用时发起的请求放行一次,这些工具在客户端里运行,受客户端自己的权限管。真正的操作
|
||||
|
||||
Reference in New Issue
Block a user