← All Posts
2026-04-24

The Loop That Learns

agents · memory · MCP · vector-db · self-improvement · architecture

Three things that don't look related

A vector database stores embeddings. An MCP server exposes tools. A self-improving agent rewrites its own behavior. These are three separate categories in the infrastructure taxonomy — storage, protocol, runtime. They show up in different vendor pitches, different conference tracks, different GitHub orgs.

But the most interesting thing happening in agent architecture right now is what happens when you connect them. Not as a pipeline, where data flows in one direction through a sequence of stages. As a loop, where each component feeds the others and the system gets measurably better over time without anyone changing the code.

This is not speculative. We run this loop. It produces 300 research briefs a day, governs its own budget, and hasn't required a code change in weeks. The architecture is simple enough to sketch on a napkin. The effects compound in ways that are worth documenting.

The vector database as institutional memory

Most agents start every session from scratch. They receive a prompt, produce output, and forget everything. The next session is a clean slate. This is not a limitation of the models — it's a limitation of how the systems around them are built.

A vector database changes this. When an agent produces output — a research brief, a code review, a planning document — the system embeds that output and stores it. The next time the agent encounters a related topic, it retrieves what it found before. Not the raw text, but the semantic neighborhood: prior findings, adjacent concepts, contradictory evidence.

The practical effect is deduplication and depth. Our research loop uses CorkScrewDB, a CRDT-backed distributed vector database with TurboQuant quantization (10x compression, SIMD-optimized), to check every new topic against everything it's already researched. At a 0.75 similarity threshold, the system catches near-duplicates before spending inference cycles on them. The result: 5,344 briefs over 26 days with minimal redundancy, despite the fact that the topic generator doesn't have perfect memory of what it's already produced.

But deduplication is the least interesting thing the vector layer does. The more important function is *context enrichment*. When the agent starts a new research cycle, it doesn't just get the topic — it gets the three most semantically similar prior briefs. That context changes what the agent produces. A brief on "CRDT-based session memory for AI agents" lands differently when the agent already has findings on cross-session learning mechanisms, entity-level version control, and MemSync architecture in its context window.

The industry data supports the value of persistent memory. Mem0's 2026 State of Agent Memory report found that agents with multi-level memory scopes (user, session, agent) produce measurably better output than memoryless agents. Letta demonstrated that intelligent context window management enables effectively unlimited memory despite fixed model constraints. The Gartner prediction that over 40% of agentic AI projects will fail cites *inadequate context management* as a primary cause — not model capability, not inference cost, but the absence of structured memory.

The vector database is the substrate. What you build on it determines whether your agent is a stateless function or a system that accumulates expertise.

The MCP server as a nervous system

The Model Context Protocol solves a problem that most agent builders hit within the first week: how does the agent use tools?

The traditional answer is function calling. You define a schema, register it with the model, and hope the model calls it correctly. This works for simple tools. It does not scale to an ecosystem. If your agent needs to interact with a code intelligence layer, a governance engine, a vector database, a web scraper, and a file system — each with its own calling convention — the integration surface becomes the primary source of bugs.

MCP replaces this with a protocol layer. Each tool exposes its capabilities through a standardized interface that includes semantic descriptions — not just "what this function accepts" but "what this function does and when you should use it." The agent discovers available tools at runtime, reads their descriptions, and invokes them through a uniform protocol. No custom integration per tool. No brittle adapter code.

This matters for self-improvement because it makes the tool surface composable. When a new capability comes online — say a structural code analysis tool built on go-tree-sitter — the agent doesn't need a code change to start using it. The MCP server advertises the capability. The agent reads the description. The next time a relevant task appears, the agent routes to the new tool.

The research confirms the trajectory. MCP adoption is accelerating across Anthropic, OpenAI, Google, and Microsoft. The expectation in the developer tooling community is that most tools will ship an MCP server by 2027. The protocol does for agent-tool integration what REST did for service-to-service communication: it makes the connection boring, which frees the interesting work to happen at the endpoints.

But here's the part that matters for the loop: MCP servers are bidirectional. The agent doesn't just consume tools — the tools can report back. A governance engine like Arbiter can expose MCP endpoints that let the agent check whether a proposed action is permitted before executing it. A vector database can expose search and storage through MCP, so the agent's memory operations go through the same protocol as everything else. The entire infrastructure becomes addressable through a single interface.

When everything speaks the same protocol, the loop closes naturally. The agent queries memory, uses tools, produces output, stores the output back to memory, and checks governance — all through MCP. No orchestration framework. No workflow engine. Just a protocol and the components that speak it.

The self-improving loop

Here's where the three pieces combine into something more than infrastructure.

A static agent has a fixed capability set. It receives tasks, executes them with whatever tools and context it has, and produces output of roughly consistent quality. Its performance on day 100 is the same as day 1, assuming the model doesn't change.

A self-improving agent gets better. Not because someone fine-tunes the model, but because the system around the model accumulates knowledge and refines its own behavior.

The mechanism is straightforward:

The agent executes a task. The vector database stores the result with its embedding. The next time a related task appears, the agent retrieves prior results as context. The quality of the new output reflects both the model's capability and the accumulated context from prior work. Over time, the context gets richer, the deduplication gets tighter, and the agent's effective expertise in its focus domains deepens.

This is compounding. The 2026 research on self-improving agents — including the HyperAgent framework's demonstration that self-improvement strategies transfer across domains — confirms that this effect is real and measurable. Self-improving agents outperform static agents over time, not because of better models, but because of accumulated context and refined routing.

The MCP layer accelerates the compounding by making new capabilities immediately available. When a better code analysis tool comes online, the agent starts using it without a deployment. When governance rules tighten, the agent's behavior adjusts in real time. The improvement isn't just in what the agent knows — it's in what the agent can do.

And governance provides the constraint that keeps the loop productive rather than chaotic. Without governance, a self-improving loop can drift: generating increasingly niche research, burning API credits on diminishing returns, optimizing for quantity over quality. Our Arbiter rules cap daily research at 300 cycles, enforce focus-area matching, gate escalation on confidence floors, and circuit-break spending at $50/day. Before governance, the research loop burned $20+/day and produced unfocused output. After governance: $0.13/day, tightly focused, consistently useful.

The Stanford-Carnegie study on human-AI collaboration found that hybrid teams outperform fully autonomous agents by 68.7%. That number isn't an argument against autonomy — it's an argument for *governed* autonomy. The governance layer is what makes the loop trustworthy enough to run unattended. The vector database is what makes it smarter over time. The MCP protocol is what makes it extensible without fragility.

Why this architecture is simple

The temptation in agent design is to build complex orchestration. Multi-agent frameworks with supervisor nodes. Workflow engines with conditional branching. Planning systems that decompose tasks into subtask trees with dependency graphs.

These work. They also break in interesting ways, and maintaining them is a full-time job.

The vector-MCP-loop architecture is simpler because it relies on emergence rather than choreography. You don't tell the agent how to improve. You give it memory (vector DB), give it access to tools (MCP), give it constraints (governance), and let the loop run. The improvement emerges from the accumulation of context and the availability of better tools over time.

This is a zettelkasten principle applied to machine intelligence. In a zettelkasten, you don't organize notes into a hierarchy. You write atomic notes, link them by association, and let structure emerge from the connections. The insight isn't in any single note — it's in the network.

A vector database is a machine zettelkasten. Each embedding is a note. Similarity search is associative linking. The agent traverses the network not by following a predetermined path but by asking "what do I already know that's relevant to this?" The structure isn't designed. It grows.

The MCP layer extends the metaphor. In a zettelkasten, you eventually need to do something with the knowledge — write an essay, make a decision, ship a product. MCP is the action layer. It connects the accumulated knowledge to capabilities in the world. The agent doesn't just know things — it can do things with what it knows.

And the self-improving loop is the daily practice. In a zettelkasten, the value comes from regular engagement — adding notes, discovering connections, refining ideas over time. The agent does this continuously: every cycle adds knowledge, every retrieval discovers connections, every output is a refinement of what came before.

What compounds

The specific things that compound in this architecture:

Domain expertise. After 5,344 research briefs across agent architecture, governance, local-first AI, and adjacent domains, the context available to each new brief is categorically richer than what was available on day one. The agent's effective knowledge in these domains is deep — not because the model is smarter, but because the memory layer contains relevant prior work on almost any subtopic the generator produces.

Deduplication precision. The similarity thresholds get more useful over time because the embedding space fills in. A threshold of 0.75 means something different when you have 100 embeddings versus 5,000. With density, the system catches finer-grained duplicates and produces more novel output per cycle.

Tool effectiveness. As MCP servers improve — better code analysis, better search, better governance checks — the agent's output quality improves without any change to the agent itself. The agent is as capable as the best available tool for each subtask. When tools improve, the agent improves.

Governance calibration. The rules get tuned based on what the system actually does. Our daily research cap started at 500 and dropped to 300 after observing diminishing returns past that threshold. The follow-up cap started at 50 and dropped to 30. Each adjustment makes the loop more efficient. The governance layer learns from the system's behavior, even though the rules themselves are declarative.

None of these require model changes. None require code deployments. The system improves because the environment it operates in improves — more memory, better tools, tighter governance. The model is the one variable that stays constant while everything around it compounds.

The economics of compounding

This matters because of cost.

A static agent costs roughly the same to run on day 100 as on day 1. Its value is linear: each cycle produces roughly the same quality output at roughly the same cost.

A self-improving agent's cost stays flat while its value increases. The inference cost per brief is the same. The governance cost is the same. But the output quality improves because the context is richer, the deduplication is tighter, and the tools are better. The cost-per-useful-output decreases over time.

This is the real economic argument for local-first infrastructure. When your vector database runs on your hardware (zero marginal cost per query), your governance engine is a local gRPC service (zero marginal cost per check), and your model inference runs on a local GPU (zero marginal cost per token for routine work), the compounding is free. The system gets better and the cost doesn't increase.

Cloud-only architectures don't compound this way. Every query to a hosted vector database costs money. Every inference call costs tokens. The improvement still happens — more context, better retrieval — but you pay for it linearly. The compounding exists in quality, but the cost compounds too.

The architecture we run — local vector DB, local governance, local inference for routine work, cloud overflow for hard tasks — optimizes for the compounding effect. The local components handle the volume. The cloud components handle the exceptions. The ratio shifts over time as the local components get better at handling more.

Before governance: $20+/day, unfocused. After governance: $0.13/day, focused and compounding. The difference isn't a model improvement. It's a systems improvement.

What this means for builders

If you're designing an agent system that needs to get better over time, the minimum viable architecture is three components:

A vector database that persists what the agent learns. Not a cache. Not a conversation history. A semantic memory layer that makes prior knowledge retrievable by relevance, not by recency.

An MCP interface that makes tools discoverable and composable. Not hardcoded function calls. Not a fixed tool registry. A protocol layer that lets you add capabilities without modifying the agent.

A governance layer that constrains the loop. Not just cost caps — though those matter. Focus enforcement, quality gates, escalation thresholds, and the circuit breakers that keep a self-improving system from self-improving in the wrong direction.

Connect the three through a simple loop: perceive → retrieve → act → store → govern → repeat. No orchestration framework. No workflow engine. No supervisor agent.

The genius is in the simplicity. The value is in the compounding. The loop that learns is not a complex system — it's a simple system that runs long enough for the compound effects to become undeniable.

---

Building a system that compounds?

ResonanceWorks works with founders and small teams on agent architecture, governance, and self-improving system design. Talk to Consulting.

Want a system with the loop built in?

Torque Engineering installs performance-tuned private AI with vector memory, Arbiter governance, and local-first compounding economics. Get Early Access.

Exploring human-machine culture?

Entrainment House publishes music, art, and cultural works shaped through human-machine coordination. Enter the House.