Agent Memory

Project memory for a coding agent

Give a coding agent persistent project memory over MCP so it stops forgetting decisions, corrections and rules between sessions.

Problem: A coding agent forgets the project's decisions, the user's corrections and its rules in every new session; it repeats the same mistakes and asks the same questions.

Solution: Connect the agent to Agent Memory over MCP. Have it recall at the start of a task, write what is durable during the task, distill at the end, and report the outcome. Put fixed project-wide information in blocks.

1. Connect

In the console, create an API key for your project (read, write, feedback, curate). Add it to your client:

{
  "mcpServers": {
    "agent-memory": {
      "url": "https://memory.empecta.com/v1/mcp",
      "headers": { "Authorization": "Bearer amk_..." }
    }
  }
}

Keyless sign-in through the browser (OAuth) is on the roadmap; for now every client connects with an API key. Details: Connect with MCP.

2. Write the project's fixed information to blocks

For short information that applies to every task:

curate_block(label="tech_stack", action="add", value=".NET 10, PostgreSQL 17, Redis 7, EF Core")
curate_block(label="coding_conventions", action="add", value="All entity IDs are Guids; async methods end with the Async suffix")

Blocks appear at the top of every search_memory output, regardless of the query.

3. The agent's loop

The server passes this loop to the agent as instructions; also add it to your client's project instructions (for the text, see Connect with MCP).

At the start of a task:

search_memory(query="numbering and error format in the invoicing module", runId="issue-482")

The output is split into sections: blocks, platform/tenant rules, workspace history, procedures, similar tasks and this run's current memories; (receipt …) comes last.

During the task, as soon as something durable happens:

EventCall
A design decision was madeadd_memory(type="decision", content="Invoice numbers are generated sequentially per tenant with a year prefix; a DB sequence prevents collisions", runId="issue-482")
The user corrected the agentadd_memory(type="correction", content="Error responses must use ProblemDetails, not plain text", runId="issue-482")
A rule was brokenadd_memory(type="violation", content="Raw SQL was used directly in a controller; the repository layer was bypassed", runId="issue-482")
The user approved a solutionadd_memory(type="approved_pattern", content="Idempotency-Key + unique index for idempotent commands", runId="issue-482")
An important fileadd_memory(type="artifact_ref", content="Invoice numbering rules: docs/billing/numbering.md", runId="issue-482")
A new decision invalidates an old oneadd_memory(type="decision", content="…", supersedes="<old-id>", runId="issue-482")

At the end of the task:

consolidate(runId="issue-482", goal="Rework invoice numbering")

Once the outcome is known (CI finished, the user approved):

report_outcome(runId="issue-482", receiptId="<receipt from the search_memory output>",
               buildSuccess=true, testPassRate=0.97, userRating=5)

4. What happens over time?

  • Writing the same decisions again doesn't duplicate them; it strengthens their evidence.
  • New corrections supersede old decisions; old information drops out of search but can still be traced with explain_memory.
  • Patterns approved in successful tasks become procedures and appear in the procedures section for similar tasks.
  • Failed tasks feed an avoid list; facts from low-scoring runs are flagged for review.
  • If the same decision shows up in several projects, it becomes a tenant-wide rule candidate; if an admin approves it, it appears in all projects.

5. Auditing

  • See memories, supersession chains and history on the console's Memories page.
  • To see why the agent recalled something, use search_memory(..., explain=true).
  • To ask where a piece of information came from, use explain_memory(memoryId).

Responsibilities: product and application

Agent Memory providesYou / the agent provide
Durable storage, duplicate merging, consolidation, contradiction rules, procedure learning, context assembly, receiptsDeciding what to write and when (agent instructions), choosing the right type, runId continuity, reporting the outcome

On this page