Files
plugins/packages/agy-cli/test
Klarkxy 92e0417739 agy-cli 0.1.16: keep conversationKey stable across volatile openings (#947)
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.
2026-11-11 14:54:37 +08:00
..