@agent-connect/memory
v0.3.0
Published
Bootstrap durable project memory for developers and coding agents.
Maintainers
Readme
agent-memory
Project Memory
This repository keeps canonical project memory in .agent-memory/state.json.
History and checkpoints live in .agent-memory/history/.
Readable projections live in docs/agent-memory/.
Recommended reading order:
docs/agent-memory/README.mddocs/agent-memory/project-map.mddocs/agent-memory/current-focus.mddocs/agent-memory/gotchas.mdwhen debugging gets noisy or surprisingdocs/agent-memory/next-steps.mdwhen you need a clean starting point
Use npx agent-memory sync, npx agent-memory recall, and npx agent-memory query to maintain and retrieve project memory.
Durable project memory with history, recall, and query.
agent-memory is now a full memory system for repositories:
- it stores the current canonical memory in
/.agent-memory/state.json - it records durable history in
/.agent-memory/history/ - it supports configurable recall policies in
/.agent-memory/config.json - it projects the current memory into
docs/agent-memory/ - it lets you consolidate memory with
recall - it lets you retrieve memory with
query - it lets you inspect backlog and checkpoint drift with
status - it can automate import-sync and recall with
automate - it can integrate Claude Code and Codex with
integrate
Why This Exists
Repositories keep losing the same expensive context:
- architectural boundaries live across code, manifests, and half-finished docs
- current state gets trapped in chats and PR threads
- repeated gotchas are rediscovered instead of remembered
- long-lived projects need both memory maintenance and memory retrieval
agent-memory turns that into a structured repository memory system instead of a pile of static notes.
Core Model
The system now has four persistent layers:
/.agent-memory/state.jsonCurrent canonical memory bundle/.agent-memory/history/events.jsonlAppend-only history of tool runs and imported sessions/.agent-memory/history/checkpoints/Bundle checkpoints written afterinit,update, andrecall/.agent-memory/sources.jsonRegistered external history sources/.agent-memory/config.jsonRecall defaults, policy, and backlog thresholds
Readable projections still live in:
docs/agent-memory/README.mddocs/agent-memory/project-map.mddocs/agent-memory/current-focus.mddocs/agent-memory/gotchas.mddocs/agent-memory/next-steps.md
An entry block is also written into the preferred top-level entry file.
How It Works
agent-memory no longer treats markdown files as the source of truth.
Instead, it:
- collects repository context
- builds or refreshes a canonical bundle
- appends durable history events and checkpoints
- projects the active bundle into repository docs
- lets you consolidate history back into memory with
recall - lets you ask memory questions with
query - lets you inspect backlog and checkpoint drift with
status - can run local automation for import-sync and recall with
automate - can integrate chat clients and MCP tooling with
integrate
If you need to control the runtime used for synthesis, use --provider=auto|codex|claude.
Commands
Bootstrap memory
npx agent-memory initCreates a fresh canonical state, resets the history scaffold, writes the first checkpoint, and projects the bundle into docs.
Refresh current memory
npx agent-memory updateRefreshes the active canonical bundle from current repository evidence and writes a new checkpoint plus tool-run event.
Consolidate memory
npx agent-memory recallReads unrecalled history, proposes a consolidated bundle, shows summary changes and file diffs, and applies only after confirmation. The preview also includes a grouped unrecalled history summary before apply.
If no unrecalled events produced durable changes, recall exits with a clear no-op message and does not write a checkpoint or tool-run event.
--section=...to limit consolidation to part of the bundle--policy=...to apply policy presets such as imports-only or project-map protection--show-diffto expand from summary-first preview into file-level diffs
Query memory
npx agent-memory query "how does caching work?"Returns a short answer plus citations from bundle sections, history events, and checkpoints. Natural-language structured questions such as what changed recently?, what should I do next?, and what are the known traps? are supported through the same command.
If current memory cannot support a confident answer, query now returns an explicit evidence-insufficient response instead of bluffing.
For agent-facing automation you can request JSON output:
npx agent-memory query "what changed recently?" --output=jsonBundle citations can also be cross-linked to the generated projection docs under docs/agent-memory/.
Projects can override retrieval instructions per query mode through .agent-memory/config.json.
Add external session sources
npx agent-memory add claude-local ~/.claude --name claudeRegisters an external session source.
Sync external session sources
npx agent-memory sync --allNormalizes external sessions into durable history events.
sync may partially succeed:
- imported sessions become history events
- duplicate sessions are skipped
- broken session files are reported as failures without aborting the whole source
Each source also records sync status, last imported count, and the last sync error when applicable.
Inspect memory status
npx agent-memory statusShows:
- state and latest checkpoint id
- unrecalled backlog counts plus a grouped summary of unrecalled history
- source sync health
- checkpoint drift summary
- retention and archive summary
- the next suggested action
Local automation daemon
npx agent-memory automate start
npx agent-memory automate status
npx agent-memory automate run-once
npx agent-memory automate stopThe first Phase 4 milestone is a local built-in automation daemon.
- it runs as a repo-local background process
- it can run
sync --allandrecall --yeson a schedule - it writes runtime state under
.agent-memory/automation/ - it records the latest machine-readable run result in
.agent-memory/automation/latest-run.json - it applies retention pruning by default and archives aged history/checkpoints under
.agent-memory/archive/ - it uses aggressive auto-apply recall by default
- dirty worktrees do not block automation cycles in this first version
Retention behavior in this first policy-controls milestone:
- retention is enabled by default
- pruning only happens inside automation cycles
- pruning is archive-first, not direct hard delete
- archived batches later expire automatically from
.agent-memory/archive/ - archived data does not participate in active
query,recall, orstatusbaselines
Integrate Claude Code + Codex
npx agent-memory integrate
npx agent-memory integrate --dry-run
npx agent-memory integrate --status
npx agent-memory integrate --status --output=json
npx agent-memory integrate --repairThis command is separate from init.
initstays repo-local and never edits global chat tooling configintegratewrites Claude Code project filesintegratealso registers Codex MCP globally with a safe merge
Install UX notes:
--dry-runpreviews project/user changes without writing files--statusis read-only and summarizes Claude/Codex integration health--status --output=jsonreturns machine-readable integration status--repaironly repairs managed mismatches; it does not create missing components--dry-runand--statusnever write project files or global Codex config- normal
integratemay write user-scope Codex config when Codex integration is selected
Generated/updated files include:
.mcp.json.claude/settings.json.claude/skills/agent-memory/SKILL.mdAGENTS.md~/.codex/config.toml
Claude Code integration uses project MCP + project skills + SessionStart and Stop hooks.
Codex integration uses MCP + AGENTS.md + the local daemon.
The generated Claude skill and Codex guidance now prefer the higher-level MCP workflow tools:
memory_assessfor a quick health and readiness checkmemory_compact_handoffbefore compact or session handoffmemory_maintainfor a one-shot maintenance pass- lower-level tools such as
memory_query,memory_status,memory_validate, andautomation_*only when finer control is needed
MCP server
npx agent-memory mcpThis starts the local stdio MCP server used by Claude Code and Codex integrations.
The MCP server exposes:
- high-level workflow tools:
memory_assess,memory_compact_handoff,memory_maintain - lower-level retrieval and health tools:
memory_query,memory_status,memory_validate - automation controls:
automation_status,automation_ensure_running,automation_run_once
Ensure automation is running
npx agent-memory automate ensure-runningThis is the lightweight startup command used by Claude Code SessionStart hooks and can also be called directly.
Self-host dogfood
This repository can also exercise itself as a long-lived dogfood arena.
npm run dogfood:init
npm run dogfood:exercise
npm run dogfood:repair
npm run dogfood:statusOptional provider override:
AGENT_MEMORY_DOGFOOD_PROVIDER=claude npm run dogfood:initCurrent dogfood behavior:
- repo-root
.agent-memory/,docs/agent-memory/,.mcp.json,.claude/, andAGENTS.mdform the stable self-host baseline exerciseruns in an isolated git worktree undertemp/dogfood/worktree- dogfood now inherits your real
HOMEby default, so Codex and Claude use the same user-level auth/config they would during normal local work - tests and other isolated runs can still override
HOMEexplicitly when they need a sandbox - dogfood structured runs now do a real provider preflight instead of trusting
--versionalone, soautocan fall back when one backend is installed but not authenticated - reports are written under
temp/dogfood/reports/ repairfirst does deterministic maintenance/integration repair, then can escalate to whole-repo provider-driven repair if source-level breakage remains- successful repair only applies a patch back to the root worktree; it does not auto-commit or auto-push
Audit health
npx agent-memory validateAudits state integrity, history continuity, checkpoint presence, projection alignment, entry wiring, and recall backlog health.
It also inspects retention config plus archive batch health under .agent-memory/archive/.
Troubleshooting
Common cases:
syncreportsfailed=...The source is still registered, but one or more session files could not be parsed or normalized. Runagent-memory validateto see whether this is now a warning condition.recallsaysNothing to recallEither there are no unrecalled events for the selected scope, or consolidation produced no durable bundle changes.statussuggestsrecallThe backlog is above the configured threshold or the checkpoint drift summary suggests stale active memory.querysays there is not enough evidence The current bundle, history, and checkpoints do not support a confident answer yet. Import more history or runrecallbefore asking again.validatewarns about recall backlog New history has accumulated and should be consolidated withagent-memory recall.
Breaking Change
This is a destructive model change.
- old
state.jsonformats are not supported - old projection markers are not supported
- there is no migration path
- old repositories must rerun
npx agent-memory init
Learn More
License
MIT
