A parked session was keyed on the client's instructions as written. agy
keeps the instructions a session was opened with, so a Codex conversation
parked under 0.1.47 (whose "You are a coding agent running in the Codex
CLI" line went to agy as written, and was turned away) was resumed after
0.1.48 began rewording that line, and every turn on it went on getting
429 for up to the 6h resume window. jx407 found this on #1151.
The parked hash is now taken over the instructions as agy is sent them
(outgoing: the turned-away lines reworded), with the same clock and billing
stripping as before. When the rewording changes, the parked session is not
taken and a new one is opened; when it doesn't, it resumes as before.
Run (WSL magpie-desktop, from the repo root, HOME a temp dir):
- packages/agy-cli `bun test`: 21 pass, 0 fail.
- node --test test/conversation-key.mjs: 34 pass, including the new
"#1151: a parked session is keyed on the instructions as agy was sent
them".
Broken by hand: with park/takeParked hashing instructionsIdentity again,
the new test fails (33 pass, 1 fail).
Not tried: a real agy session parked under 0.1.47 and resumed under this
version.
A Codex tool loop with view_image screenshots grew the plugin host to
0.5-1.5 GiB after GC, so magpie recycled it every ~10 minutes and the
mid-turn conversation restarted without its tool outputs (tungloong's
report).
- Turn.registerResponse drops the previous step's body and
contentSnapshot. Only the current step's are read again (a late
prompt's estimate); the usage reducer reads settled/usage only.
- historyKey keys a tool_result image by mimeType + sha256, as it
already keys a user's image, instead of copying its base64 into the
key on every comparison.
Old data: a conversation parked before the update with an image inside
a tool result has a history hash taken over the raw bytes, so it starts
a new agy session once instead of resuming. Others are unchanged.
Run (mote, sandbox HOME): node --test conversation-key, step-usage,
usage-settlement, repeat-batch, compat: 128 pass. bun test: 21 pass.
scripts/check.mjs ok. Broken by hand: with origin/main's index.mjs both
new tests in conversation-key.mjs fail (2 of 33).
Not tried: a real Codex Desktop screenshot loop; heap size not measured.
conversationKey stays stable when only agent-injected opening fields
change (Claude Code's billing header, known clock lines in the system
prompt or a <system-reminder>), so a continued chat keeps its agy session
and its prompt cache. It hashes the whole stripped first message. A
flattened, growing first message reuses the live session only when it
continues the whole previous opening plus that session's reply on a line
boundary, and then sends agy only the new tail. Closes#945.
Reviewed head 56c845720026819781e198bada948cce9b926806 (one commit on
main 9204c07; main 9e07c706 has no agy-cli change since).
Both points from the last review are fixed:
- A reused flattened session no longer gets the opening again. A probe of
four flattened turns with empty history (200 İ, ß, ffi, Dž, ς, 𝐀😀 in the
opening, a reminder date that changes every turn, replies with thinking)
ran in one fake agy session; prompts 2-4 were 28, 16 and 16 bytes and
held only the new step.
- The reminder scan folds only ASCII, so İ before a reminder no longer
shifts indexes. An upper-case <SYSTEM-REMINDER> after İß keeps the key
across a date change and reuses the session.
Broken by hand, each went red: the old slice(history.length) prompt (5
red), toLowerCase() (2), no user-id check (1), join("") in systemText (1),
compactIdentity in takeParked (1), no line-boundary check (2),
findLiveContinuedProc returning null (6).
Run at the head on main 9e07c706:
- Linux (WSL2 Ubuntu 24.04, Bun 1.4.2, temp HOME): bun test packages/agy-cli
11 pass, 0 fail; bun scripts/check.mjs exit 0.
- Windows 11 (temp HOME and USERPROFILE): 10 pass, 1 fail; the one red is
the smoke check "no call to the loaded tool reaches agy's validator in
the old prompt", the only red at origin/main 9e07c706 too (9 pass, 1
fail), filed as #973. check.mjs exit 0 on both.
- #971's loose matchesHistory/takeParked and 0.1.12's cache estimate are
unchanged; compat, smoke and usage-settlement pass.
Not blocking: if updateTools throws after a flattened reuse is picked,
pendingFlattenedTurn stays on the process. After an agy error on a reused
flattened turn, the same request again starts a new session with the full
opening, as a fresh retry does on main.
Not tried: a real agy or a real flattening client.