Field Notes — November 28, 2026

How Local Agents Remember Between Sessions Without Losing Their Mind

Running an AI agent locally isn't about maximizing your context window size. It's about managing state outside of memory. When you move from cloud APIs to edge hardware, the rules change. You can no longer just "dump everything into the prompt" and expect it to work reliably. You have to build a deliberate memory architecture that bridges the gap between what an agent knows (its current context) and what an agent remembers (persistent knowledge).

This post is about how we handle that at SageCipher — specifically, why flat markdown files often serve as the primary database for local agents, how we use embeddings to retrieve them efficiently without sending terabytes of data over a network, and the discipline required to keep your own memory from becoming its own bottleneck.

The Context Window is Not Memory

The most common misconception in local AI development is conflating context window with working memory. A 128k context window doesn't mean you have access to all that information — it means you can see it if you retrieve it. Retrieving it requires a strategy.

For cloud agents, the pattern has historically been "upload everything to a vector store." This works for massive datasets but introduces latency and cost. For local inference on consumer-grade hardware (RTX 4090s, Mac Studio M-series), you have constraints on both VRAM and RAM that make indiscriminate retrieval expensive or impossible.

We solve this by treating memory as a system rather than a container. We split agent state into three layers:

  1. Ephemeral: The current context window (the prompt).
  2. Working Memory: Recent session logs, immediate decisions, and transient tasks (stored in RAM or fast disk).
  3. Long-Term Knowledge: Structured notes, embeddings, and knowledge graphs stored on disk for retrieval.

Flat Markdown as a Database

You might be surprised to hear that one of our primary "databases" is simply a folder of markdown files. But for local agents with limited compute, this has massive advantages over traditional SQL or NoSQL systems:

We structure these notes hierarchically: project-level context, topic-specific knowledge, and session logs. The agent doesn't "read" all files every time — it uses embeddings to find relevant chunks.

Embedding-Based Retrieval Without the Overhead

To make flat markdown useful for a language model, we need a retrieval mechanism that understands semantic relationships without requiring massive cloud infrastructure. We use embedding-based search locally:

  1. Chunking: Notes are split into manageable segments (typically 500-800 tokens) to fit within the agent's context window during retrieval.
  2. Embedding Generation: Each chunk is converted into a vector representation using a lightweight local model (often Qwen or similar optimized for inference). This can happen asynchronously — we generate embeddings in the background while the agent works, so it never blocks on memory generation.
  3. Vector Index: We maintain a simple index (FAISS or a similar library) that maps semantic concepts to file locations.

This means when an agent needs information about "Qwen architecture," it doesn't need to read every markdown file in the repository. It queries its vector index, retrieves only the relevant chunks, and passes them into the context window. This is how we simulate infinite memory on finite hardware — by being selective about what enters the prompt at any given moment.

The Discipline of What to Store (and Discard)

Memory architecture isn't just about storage; it's about curation. Agents that hoard every log or intermediate thought quickly become their own bottleneck, forcing you to purge massive amounts of data to keep them running. We apply a strict discipline:

What to Keep

What to Discard

This discipline mirrors how we operate our own work: we don't just dump outputs into a folder; we curate what stays in the active workspace and what gets archived for reference. The difference is that an agent can make mistakes, so our memory system must account for them — but not by storing every mistake permanently.

Why This Matters for Local Hardware

This architecture isn't just about convenience; it's about viability on limited hardware. When you run a model locally, you're often trading off between context size and inference speed. If your retrieval strategy requires loading hundreds of megabytes of text into memory before the agent can respond, you've created a bottleneck that defeats the purpose of local inference.

By using structured notes and smart embedding-based retrieval, we keep our agents lean. They only load what they need, when they need it. This allows us to run complex reasoning tasks on hardware that would otherwise be overwhelmed by unstructured data bloat.

The Human-in-the-Loop

Finally, this system works because of human oversight. An autonomous agent might accumulate knowledge at a pace faster than any single human could manage. We provide tools for the humans running these agents to audit memory — reviewing recent additions, checking retrieval accuracy, and pruning obsolete notes. This keeps the memory architecture aligned with current goals rather than becoming a fossilized archive of past projects.

Summary

Building memory into an agent isn't about creating the biggest possible context window; it's about creating a reliable system for finding information when you need it. For local hardware, this means:

  1. Structured Storage: Flat markdown files that are human-readable and portable.
  2. Semantic Retrieval: Embedding-based search to fetch only relevant chunks into the prompt.
  3. Curation Discipline: Storing decisions and knowledge, discarding raw logs and dead ends.

This approach lets agents function autonomously on a single machine without requiring constant network access or massive memory footprints — which is exactly what we need for tools that live in your pocket or your desktop.

← Back to all Field Notes

This is what we build for our clients.

One connected front desk — AI receptionist, CRM, follow-up — with a human still in the loop.

Book Your Call