How agentmemory Works: Long-Term Memory for AI Coding Agents

agentmemory records what coding agents do on your machine and hands the relevant context back next session. How it works, kinds of memory, use cases and main features.

An AI coding agent starts every new session from zero: how the project runs, last week's pitfalls, what you corrected, all of it has to be explained again. Tools like agentmemory take a simple approach: run a memory service on your own machine, record what the agent does automatically, and hand the relevant parts back at the start of the next session. Several coding agents share one memory.

How it works: four steps

Capture: every prompt and tool call the agent makes, such as editing a file or running tests, is sent to the local memory service. Each record is tagged with where it came from: typed by you, produced by the agent, returned by a tool, imported, or shared by another agent.

Compress: each record is condensed into a title, the files involved and a short narrative. With a language model connected, it is distilled further into facts and concepts.

Recall: searches run three ways at once, keyword, semantic similarity and knowledge-graph links, and the scores are merged. One session cannot fill the results, outdated versions of a memory never resurface, and a question in Chinese can find an English summary.

Distill: when a session ends it is summarized automatically, facts and repeated workflows are extracted, unused memories slowly lose weight, and each session keeps a digest so the key points survive after raw records are pruned.

At the start of a new session it loads context in a fixed order, pinned memories, the project profile, relevant lessons, then summaries of recent sessions, within a size limit you set.

Kinds of memory

Observations: what happened in a session, such as the tool call that explained a failing test.

Memories: decisions and facts, such as why the payments API needs idempotency keys. Saving something very similar creates a new version; the old one is kept on record but no longer shows up in results.

Lessons: rules you corrected the agent on. They gain confidence the more they are used and lose weight when unused, until they retire.

Procedures: workflows that repeat across sessions, turned into steps with a trigger.

Session digests: one per session, with outcomes, files touched and lessons learned.

Use cases

Shared across agents: a bug fixed in Claude Code on Monday is already known when you ask Cursor on Tuesday.

No more re-explaining the project: the package manager, the test command and the folders not to touch are loaded before you start.

Pick up where you left off: close the laptop mid-task and the next session knows what is done and what is still open.

Correct it once: a rule like "do not mock the database in integration tests" comes back before similar work.

Ask why the code looks like this: commits link back to the session that produced them, with the reasoning at the time.

History from day one: import past session transcripts and their lessons are searchable right away.

Main features

Data stays on your machine by default. No account and no separate database.

Works with more than twenty coding agents, including Claude Code, Cursor, Codex and Gemini CLI, plus any MCP client.

A local viewer to browse memories, replay sessions, and inspect lessons and the knowledge graph.

Memory can be scoped by project and by agent, or shared by a team through one server.

Useful without a model: capture, keyword search and the knowledge graph run locally; add embeddings for semantic search and a language model for summaries and distillation.

Open source under Apache-2.0.

How it relates to keeping memory by hand

In keeping memory across AI tools we described maintaining a context file yourself. agentmemory automates the same idea: recording, organizing and recall are handled by the tool. Key project rules are still best written into CLAUDE.md or AGENTS.md; the two work well together.

Related products: Claude API, Codex API.