Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

Merge PR #728: read a spool entry's fields in linear time (#727)

AkitaOnRailsd3d3a8a23556
diff --cc CHANGELOG.md
index 5ba6fce2,57f3fe14..d191de4e
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -7,50 -7,20 +7,63 @@@ and this project adheres to [Semantic V
## [Unreleased]
+### Security
+- Updated `rustls` 0.23.40 → 0.23.45 for [RUSTSEC-2026-0285](https://rustsec.org/advisories/RUSTSEC-2026-0285),
+ in which a TLS 1.3 handshake message that follows a key-changing message in
+ the same record can be accepted at the wrong encryption level. `rustls` is a
+ direct dependency — it installs the process-wide crypto provider the MCP
+ bridge needs for HTTPS — and is also the TLS implementation every outbound
+ HTTPS call resolves to through reqwest, so the advisory failed `cargo audit`
+ and `cargo deny check` on every open pull request that inherited `main`'s
+ lockfile, including ones that change no Rust at all. `Cargo.toml` already
+ allows compatible 0.23 patch releases, so this is a lockfile-only change
+ needing no manifest or public-surface edit; the same resolution moves
+ `rustls-webpki` 0.103.13 → 0.103.15 and nothing else (#731).
+
### Fixed
+- The native `ai-memory hook` session-id state file
+ (`<data_dir>/hook-state/<agent>-session-id`), introduced for Devin in #178,
+ now also covers ZCode. ZCode's hook payloads do not reliably carry a session
+ id, it fires `Stop` at the end of every turn, and it has no `SessionEnd`
+ event — without a persisted id, each turn with an id-less payload opened a
+ fresh server-side session that nothing ever closed (observed in production:
+ 4 sessions with NULL `ended_at` and 398 observations stuck in episodic).
+ ZCode events without a native id now share one stable stored id per agent
+ session; events carrying a native id are passed through untouched. The stored
+ id is cleared by `finalize-session --agent zcode` (which now also removes the
+ state file) or overwritten by the next `session-start`; `Stop` never clears
+ it. Other agents are unaffected: payloads that carry a session id short-circuit
+ the state file exactly as before.
+- `memory_feedback`'s `signal` (FeedbackKind) JSON schema now declares a
+ top-level `type: "string"`, so strict function-calling gateways (Moonshot/Kimi
+ and other schema validators) accept the `tools/list` surface instead of
+ rejecting the enum for a missing type (#735, #741).
+- Cursor lifecycle events are no longer stored twice on a host where both
+ `install-hooks --agent cursor` and `install-hooks --agent claude-code` are
+ applied. Cursor also runs the commands in Claude Code's settings, and since
+ 2.1.0 that copy is re-attributed to `cursor` by its `cursor_version`, so it
+ landed in the same session as the native event. The `--agent claude-code`
+ hook now drops a Cursor-marked payload when `~/.cursor/hooks.json` already
+ registers an ai-memory `--agent cursor` hook; without Cursor's own hooks the
+ Claude Code path keeps capturing Cursor sessions as before (#721).
+- `install-hooks --agent cursor --apply` now warns about existing
+ `~/.cursor/hooks.json` entries that mention ai-memory but are not ai-memory
+ hook entries, such as a pre-2.1.0 shim that injected `cwd`. Those entries
+ are kept beside the native ones, so every event would otherwise be captured
+ twice without any sign (#721).
+ - The POSIX shell hook bundle's spool reader no longer builds the decoded value
+ in memory. `ai_memory_json_field` appended to a string that grows to the whole
+ value, so reading a multi-megabyte entry — one large tool result is enough —
+ took minutes of CPU, and a drain pass reads every entry three times (`url`,
+ `body`, `token`) while one detached pass starts behind every delivery that
+ succeeds. Once an outage had filled the spool, the passes accumulated faster
+ than they retired and saturated the machine. The value is now bounded by a
+ single regex pass over the JSON string grammar, unescaped with `gsub` over
+ whole segments and written straight to stdout, for identical output and exit
+ codes. A 2.2 MB entry of `grep` output — the shape that caused the incident,
+ where every literal backslash is an escaped pair — goes from 732 s to 5.5 s
+ under the awk macOS ships and from 9-10 s to about 1 s under mawk and gawk
+ (#727).
## [2.2.1] - 2026-09-12