AgentsInFlow
AgentsInFlow

Memory

Durable, persistent intelligence that survives across sessions. The more you use it, the better agents perform.

How Memory Works

Memory operates on a three-pipeline model that runs automatically during the execution lifecycle. Each pipeline handles a distinct phase of knowledge management.

Recall

Before execution

Queries memory for relevant prior context and injects it into the agent's prompt. The agent starts every session aware of past decisions, known procedures, and learned principles.

Index

After execution

Indexes completed session transcripts and tickets into a full-text search database, making them available for future recall queries.

Extract

After execution

Analyzes indexed sessions to extract high-value, durable learnings as structured records. Only concrete facts are persisted — never chain-of-thought, raw transcripts, or debug artifacts.

[Screenshot: Three-pipeline memory flow showing Recall, Index, and Extract stages across the execution lifecycle]

Memory Scopes

Memory is organized into two scopes that work together during recall. Both scopes are queried simultaneously so agents receive both project-specific knowledge and your personal preferences in every session.

Project ScopeAssistant Scope
StoresDecisions, procedures, incidents, principles, preferences tied to this codebaseYour personal preferences, communication rules, and interaction patterns across all projects
IndexedSession transcripts, tickets, and recordsRecords only (no session transcripts)
SharedAcross all agents working on the same projectAcross all projects for the same user
Example"Use pnpm, not npm" for this repo"Prefer concise responses" everywhere

Assistant scope follows you across projects. When an agent learns that you prefer snake_case naming or short commit messages, that preference applies to every project you work on.


Record Categories

Every memory record belongs to one of five categories. The extraction pipeline classifies records automatically, and you can reclassify them manually if needed.

CategoryWhat it capturesTemporal
decisionsImplementation choices, architectural trade-offs, technology selectionsPermanent
proceduresStep-by-step workflows, build processes, deployment sequencesPermanent
principlesCoding standards, design rules, constraints that guide future workPermanent
incidentsBugs encountered, root causes, and their fixesTemporary or permanent
preferencesUser preferences, communication style, naming conventionsPermanent

Memory never stores secrets, API keys, passwords, raw transcripts, or chain-of-thought reasoning. Only durable, concrete facts are persisted.


Recall: Context Injection

When an execution starts, the recall pipeline queries both memory scopes using the ticket description as a search query. Matching records and session snippets are assembled into a context brief that is injected into the agent's system prompt.

1

Ticket description and context are used as the recall query

2

FTS5 full-text search scores and ranks matching records and session chunks

3

Top results from both project and assistant scopes are merged into a single context brief

4

The brief is injected into the agent prompt as prior context, with source references and relevance scores

[Screenshot: Agent prompt showing injected recall context with record references and relevance scores]

Recall is automatic. You do not need to manually select which memories to include — the system retrieves the most relevant context for each execution based on the task at hand.


Record Storage

Records are stored as individual Markdown files with YAML frontmatter, organized by category. The search index is an SQLite database with FTS5 enabled for fast full-text search.

.aif/memory/state/
records/
decisions/ *.md
procedures/ *.md
principles/ *.md
incidents/ *.md
preferences/ *.md
index.sqlite — FTS5 search index
RECALL_CONTEXT.md — pre-built recall brief
extraction.log — extraction history

Each record file contains structured frontmatter (category, creation date, source, aliases, search keywords) followed by the record content. Records are human-readable and can be edited directly in any text editor.

[Screenshot: Example memory record Markdown file showing YAML frontmatter and content body]

Search & Retrieval

Memory search uses SQLite FTS5 for ranked full-text search across records and indexed session chunks. Results are scored by relevance and returned with source references so you can trace any recalled fact back to its origin.

What gets searched

  • Records — durable facts extracted from past sessions (decisions, procedures, etc.)
  • Session chunks — indexed segments from past execution transcripts
  • Ticket content — indexed ticket descriptions and notes

Recall output formats

FormatUse case
snippetsCompact ranked list of matching text fragments with scores
promptPre-formatted context ready for injection into an agent prompt
jsonStructured JSON output for programmatic consumption

Managing Records

While extraction is automatic, you have full manual control over records. You can add, update, reclassify, archive, or delete any record.

OperationDescription
record addCreate a new record in a specific category and scope
record updateModify the content or metadata of an existing record
record reclassifyMove a record to a different category
record archiveSoft-remove a record from recall results without deleting the file
record deletePermanently remove a record
record listList all records, optionally filtered by category
record getRetrieve the full content of a specific record by ID

You can also ask any agent to add a memory record during a session. Tell the agent what to remember, and it will create the appropriate record with the right category and scope.

[Screenshot: Terminal showing record list output with categories, IDs, and content previews]

Compounding Knowledge

Memory improves agent performance over time. Each completed execution potentially adds new records, and every future execution benefits from the growing knowledge base.

First sessions

Agents start with minimal context. They may rediscover patterns, ask about conventions, or make decisions that need correction.

After 10+ sessions

Agents recall project conventions, known pitfalls, and your preferences. Common mistakes stop repeating. Build procedures are followed without prompting.

Mature projects

Hundreds of records across categories give agents deep project awareness. Incidents are avoided because fixes are already known. New agents on the same project inherit the full knowledge base immediately.

Memory is a shared team resource at project scope. When one agent learns something, every agent on the project benefits on their next execution.