Project memory is what the project knows, kept across agents: events, memories, artifacts and
reports, all in state.db and searched with SQLite's FTS5 — the store itself calls no model
and embeds nothing. It lives in internal/memory, fed automatically from
the daemon's own chokepoints, thinned by consolidation, and sliced per-agent by a context builder.
flowchart LR
Daemon["Daemon chokepoints\ninternal/daemon/memoryevents.go"] -- "captureEvent()" --> Events[("events")]
Events -- "mechanical + distillation passes\ninternal/memory/consolidation.go" --> Memories[("memories")]
Events --> Reports[("agent_reports")]
Memories --> Context["Context builder\ninternal/memory/context.go"]
Reports --> Context
Context -- "brief.md\nbudgeted slice" --> Agent["An agent's AI tool"]
Context -- "full budget" --> Lead["The lead"]
Lead -- "remember / memory_feedback / project_state" --> Memories
Agent -- "report / record_artifact" --> Reports
memory.go— the core types:Event,Memory,Report,WorkingMemory,Artifact.search.go— the FTS5 search used bysearch_memory.consolidation.go— the mechanical pass (duplicates, decay, exact merges) plus thePass/Statstypes logged toconsolidation_passes.context.go— the context builder.repo.go— memories shared through the repository: the.agentbox/memoriesfile format, the import every read runs, and the export sharing commits.events.go,memories.go,artifacts.go,reports.go,working.go— CRUD/query methods for each table.
erDiagram
events ||--o{ memories : "source_event_id"
memories ||--o{ memories : "supersedes_id"
memories ||--o{ memory_duplicates : "memory_id / duplicate_of"
events ||--o{ consolidation_passes : "through_event watermark"
events {
int id PK
string project FK
string agent
string session
string type
string payload
int artifact_id
}
memories {
int id PK
string project FK
string kind
string title
string content
int importance
int supersedes_id FK
int source_event_id FK
string referenced_at
string decayed_at
string resolved_at
}
working_memory {
string project PK
string data
string updated_at
}
artifacts {
int id PK
string project FK
string agent
string type
string path
string metadata
}
agent_reports {
int id PK
string project FK
string agent
string task
string status
string summary
string discoveries
string decisions
string remaining_issues
}
memory_duplicates {
string project FK
int memory_id FK
int duplicate_of FK
float similarity
}
consolidation_passes {
int id PK
string project FK
string kind
int events_read
int memories_written
int through_event FK
string model
}
- events — append-only raw history (
internal/state/state.go, migration 23), one row per thing that happened. Indexed for FTS5 (events_fts, overtype/payload). - memories — the distilled, still-live knowledge (migration 24), FTS5-indexed
(
memories_fts, overtitle/content).supersedes_idlinks a memory to the one it replaces;resolved_at/decayed_atmark it no longer live without deleting it. - working_memory — one row per project (migration 25): goal, current task, active agents,
blockers, freeform notes, as JSON in
data. - artifacts — references to things an agent produced (migration 26): a path plus metadata, not the content itself.
- agent_reports — an agent's structured finish record (migration 29), FTS5-indexed
(
reports_fts): task, status, summary, discoveries, decisions, remaining issues. - memory_duplicates — near-duplicate candidates the mechanical consolidation pass finds (migration 30).
- consolidation_passes — a log of each consolidation run and what it did (migration 32).
- memory_serves — which agents' briefs carried which memory, one row per memory and agent
(see Memories that could be notes).
memories.promotionsays where a memory stands as a candidate note.
search_memory runs a two-pass FTS5 query (search.go): a strict pass (phrases AND-ed together)
first, then a loose pass (OR-ed) to fill in anything the strict pass came up empty on, without
overwriting what it already found. Hits are then reranked — not just left in bm25 order — by a
blend of bm25 score (65%), recency with a 14-day half-life (20%), importance (10%), and kind, with
project-level/decision memories weighted above episodic ones (5%). Superseded or resolved memories
are excluded before the search ever runs. Results come back as three separate ranked lists:
memories, events, reports.
The daemon writes events at its own chokepoints, not something an agent has to remember to do —
internal/daemon/memoryevents.go's captureEvent() is the
generic entry point, called after things like:
- an agent finishing (
captureAgentFinished()) — diff stats, PR link, its report's summary.
captureArtifact() records a reference whenever something citable is produced.
Events accumulate; consolidation turns them into fewer, longer-lived memories
(internal/memory/consolidation.go):
- Mechanical pass — pure SQLite, no model: finds near-duplicate memories (Jaccard similarity over normalised title words, same kind), merges exact ones (same title, one contains the other verbatim), and decays importance on episodic/issue memories nobody's referenced in 30+ days.
- Distillation pass — runs a model over a window of up to 300 recent events plus the current
live memories, writing new/superseding memories and a
memory_consolidatedevent. It runs on the project's own chat's cheap model by default (consolidation_model = "cheap", resolved per AI tool), in a session of its own — not the agent's or lead's live conversation — configurable per project (state.go:consolidationsets the event-count trigger, default 200;consolidation_modelpicks the model).
Every pass, mechanical or distillation, is logged to consolidation_passes with its cost
(events read, memories written/superseded/resolved/decayed, duplicates found, bytes in/out).
A few memories hold in every project rather than one: the user's preferences ("Agent preference:
only one agent at a time") and conventions they want everywhere. They are written only on purpose
— a project's lead uses remember with scope all when the user asks for something to apply to
all their projects, and the Home chat's remember writes nothing else — and nothing is ever
promoted there automatically. They are kept in the same memories table under the project *
(global.go), with the project or chat that wrote them in origin.
Every project's search_memory returns them beside its own memories, marked "all projects", and
every context has a "What holds in every project" section of them, after the open issues and
within the same budget. A lead can supersede one (with scope all again) or resolve it; the user
sees them in Settings → Memory and deletes them there. Decay, distillation and tidy never touch
them.
A project's memory is on your machine. To give what its agents learned to the people you work with, share it through the project's repository: in the native app, open the project's Memories page (the brain button on the project's row in the sidebar, or the row's menu), tick some memories or press Share all.
Sharing commits one Markdown file per memory, .agentbox/memories/<id>.md, on the branch
agentbox/memories (your project's branch prefix, then memories). The commit is made without
touching your checkout: whatever branch you are on, your files and your index stay as they were.
Push the branch and open a pull request (the page shows the git push command); a co-worker
reviews the memories like any other document. Sharing again adds to the same branch until it is
merged, and starts from the base branch after that. The lead can share too, when you ask it to
(POST /v1/project/memory/share).
---
id: mem_3f2a…
kind: decision
title: "Deploys happen on weekdays only"
importance: 4
created: 2026-11-16T09:30:00Z
updated: 2026-11-16T09:30:00Z
supersedes: ["mem_91c0…"]
---
Two Friday deploys broke the checkout. …Whenever AgentBox reads a project's memory (the Memories page, search_memory, an agent's brief),
it first reads the .agentbox/memories folder in the project's checkout, when it changed. Each file
becomes a memory marked from repository, found and ranked like any other. Editing a file
updates it; deleting the file removes it (AgentBox won't delete a shared memory itself — delete its
file). A file with a broken frontmatter is skipped.
AgentBox's own copy wins. When a file has the id of one of the project's own memories, or supersedes one of them, or one of them supersedes it, it is the same memory, and AgentBox keeps the one it has: it may have been corrected or resolved since the file was written. The file is skipped. A shared file that supersedes another shared file replaces it, as memories do. Memories for every project are yours and are never shared.
BuildContext() (context.go) assembles what an agent or the lead is actually told, within a
token budget:
- Load working memory, and a search query — either given, or derived from the project's goal and current task.
- Gather bounded sections: 8 open issues, 8 memories for every project, 8 high-importance project/decision memories, 5 search hits per kind, 5 newest reports, 5 newest artifacts.
- If the budget's exceeded, drop sections by priority — working memory, the project's story and open issues are never dropped.
- Mark whatever memories were actually used as referenced, resetting their decay timer.
The lead gets the full budget (context_budget, default 4000 tokens); an agent gets a quarter of
it, since its task is narrower. This is the slice that lands in an agent's brief — see
Project notes and the brief.
When the context builder hands the same memory to agent after agent, the project is paying for it in
every brief anyway, and a project note might say it better. So each agent brief records which agents
the "What the project knows" memories reached (a brief that is only previewed counts for nobody, and
one agent's brief rewritten ten times counts once). A project, decision or discovery memory served to
5 different agents is offered to the lead, at most 3 at a time, under "Memories that could be
notes" in its brief (promote.go).
Nothing is promoted on its own: a note costs every agent context. The lead answers each offer once:
noteswithpromoteappends it to the notes (worded by the lead, or the memory's title and the start of its content) and marks the memorypromoted, so no brief serves it beside the note.search_memorystill finds it.noteswithdismissmarks itdismissed: it stays an ordinary memory and is never offered again.
An offer nobody answers lapses after two weeks and isn't made again.
- Agent-facing (
agentbox-memoryMCP server,internal/cli/memory.go):search_memory,report,record_artifact— an agent's view is scoped to its own task. - Lead-facing (
agentboxMCP server,internal/cli/mcp.go):search_memory,remember,memory_feedback(withresolved),project_state(which also updates the working memory) andnotes(promote,dismiss) — the lead can write memory directly, for its project or (scopeall) for every project; see The lead and its MCP tools.