# How to Give Your AI Coding Agent Infinite Memory

> Source: <https://dev.to/julianbrown/how-to-give-your-ai-coding-agent-infinite-memory-4ehp>
> Published: 2026-09-07 13:34:59+00:00

AI coding agents are stateless. Once a session closes, the context window resets, and the agent forgets every architectural trade-off, rejected alternative, and subtle debugging edge case you worked through.

Cramming 100k-token transcripts into prompt context causes latency spikes, attention dilution, and cost bloat. Naive automated summaries strip away the exact chronological rationale and specific trade-offs you actually need.

Don't stuff context. Index your past trajectories locally and let the agent query them on demand.

Think of it as giving your agent an active retrieval reflex instead of asking it to carry its entire life history in working memory. By connecting a lightweight FastMCP server to an embedded SQLite FTS5 database, the agent can search its own historical conversations in sub-10ms and pull exact past decisions using fewer than 120 tokens.

```
~/.gemini/antigravity/brain/
            │
  [<session-id>/transcript.jsonl]
            │
            ▼
┌───────────────────────────────────────┐
│ Incremental MTime Parser              │
│ (Filters noise, diffs & shell stdout) │
└───────────────────┬───────────────────┘
                    │
                    ▼
┌───────────────────────────────────────┐
│ SQLite + FTS5 BM25 Engine             │
│ (conversations.db — local keyword FTS)│
└───────────────────┬───────────────────┘
                    │
                    ▼
┌───────────────────────────────────────┐
│ FastMCP Server (stdio transport)      │
│ (Exposes search tools to the agent)   │
└───────────────────┬───────────────────┘
                    │
                    ▼
          [ Antigravity Agent ]
```

In Google Antigravity, place the server in your **global configuration** (`~/.gemini/config/mcp_config.json`), rather than the scoped workspace config (`.agents/mcp_config.json`).

Raw agent transcripts (`transcript.jsonl`) contain megabytes of raw terminal output, file overwrite diffs, and status pings. Blindly indexing this breaks BM25 search relevance.

The ingestion parser applies three strict filters:

`USER_INPUT` (steering/prompts) and `PLANNER_RESPONSE` (reasoning/decisions). Discards binary payloads, file scrapes, and transient tool poll steps.`stdout` outputs. Indexes only the tool name and target file reference (e.g., `write_to_file: target.py`).` MAX_CONTENT_CHARS = 10_000`) on individual messages to prevent catastrophic index bloat.
Store records in a local SQLite virtual table using FTS5, Porter stemming, and Unicode-61 tokenization. An `mtime` cache tracks file modification timestamps so incremental re-indexing across dozens of sessions takes less than 20 milliseconds.

The FastMCP server exposes two primary tools over `stdio`:

`search_antigravity_conversations(query="...")`: Returns BM25-ranked matches with conversation IDs, timestamps, and highlighted snippets.`get_antigravity_step(conversation_id, step_index)`: Pulls the surrounding dialogue window for full contextual fidelity.
When the agent hits friction, needs historical context, or conducts a post-mortem on earlier decisions, it calls the MCP tool directly:

```
search_antigravity_conversations(query="Observer Stance negative assertions")
```

Instead of guessing or re-reading giant raw files, SQLite returns the exact turn where the decision was made:

```
[Match 1 | Session: 8f2a-e1... | Date: 2026-09-02 14:18]
Role: PLANNER_RESPONSE
Snippet: "...decided to cut redundant negative assertions from Chapter 1. 
The observer stance works best when physical actions imply boundaries 
rather than explicitly stating what didn't happen..."
```

The complete implementation is open source on GitHub:

Stop starting from scratch every time you open a terminal. Let your agent inspect the tape.
