Persistent cross-session agent memory (user + project memory files, {memory} playbook token)#89
Merged
Merged
Conversation
…lined via {memory} playbook token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Agents now keep durable memory across sessions, in two scopes:
<data_dir>/memory/user.md, shared across all projects (preferences, working style)<data_dir>/files/<slug>/project/memory.md, inside the files dir's reservedproject/namespace (build quirks, decisions, dead ends)Both files are inlined into the playbook via a new
{memory}token (new## Memorysection in SYSTEM_PROMPT.md), so every harness (Claude Code / Codex / OpenCode) sees the content — not just a path — on every playbook render. Agents maintain the files with their native Write/Edit tools; the playbook instructs them to consolidate rather than append, to save directly when the user clearly wants something persisted ("remember this"), and to ask first when unsure.How
src/local/memory.rs: path helpers, best-effort parent-dir creation (hooked intoensure_playbookbesidefiles::ensure_dir), 4 KB/scope head-keep UTF-8-safe truncation with a visible marker, and a pure renderer (unit-testable without touching the real data dir).playbook_mdsplit into a thin wrapper +playbook_md_with_memoryso tests inject a memory stub instead of reading the developer's real files.{memory}is substituted last in the replace chain so agent-authored content can't be rewritten by later token replaces.project/memory.mdshows up in the Files tab, SSE watch, and data-dir snapshots through the existing files-dir mechanism. Local-only (cloud never renders this template).Testing
memory.rs(renderer, cap/UTF-8 boundaries, blank-file handling, path layout) + playbook tests updated ({memory}added to the placeholder-completeness list).cargo fmt --check/clippy -D warnings/cargo test --lockedall pass (194 tests).ORX_DATA_DIR, port 4903): playbook renders both scopes with seeded content; "remember that…" saved directly via a consolidating rewrite; an ambiguous preference triggered an ask-first question card; a second session's playbook picked up the first session's save; Files API lists/servesproject/memory.md; >6 KB file rendered with the truncation marker.