AI agents fail in production because of context, not models. The infrastructure between enterprise data and the AI model - the context layer - must live in the database, not above it as middleware and not inside an analytical platform as a bolt-on feature. This paper presents the SurrealDB agent infrastructure stack: a vertically integrated system spanning a distributed storage engine providing ACID storage on cloud object storage, SurrealDB (a multi-model database unifying documents, graphs, vectors, and time-series in a single engine), and Spectron (structured agentic memory with entity extraction, knowledge graphs, and temporal fact tracking). No other product ships this complete vertical. From object storage to agent memory - a single stack, a single transaction boundary.
ABSTRACT
The transition from stateless language model interactions to persistent, autonomous AI agent systems has exposed a fundamental infrastructure gap. Agents fail in production not because models lack reasoning capacity, but because they lack reliable, structured, real-time context. RAG over flat vector stores suffers from semantic fragmentation, temporal blindness, and relevance degradation at scale. Memory middleware that abstracts over multiple specialist databases introduces consistency gaps, latency overhead, and semantic drift between stores.
We argue that the context layer for AI agents must live in the database - not above it as middleware, not inside an analytical platform as a bolt-on feature - and that the database must be architecturally multi-model: documents, graphs, vectors, and time-series as native primitives in a single ACID-compliant transactional engine.
We present the SurrealDB agent infrastructure stack: a vertically integrated system spanning distributed ACID storage on cloud object storage, a multi-model database engine, and a structured agentic memory layer.
THE CONTEXT WALL
Agents fail because of context, not models
Every AI team hits the same wall. The model is capable, but the agent cannot remember what happened two turns ago, cannot connect a user preference to a product entity, and cannot guarantee that concurrent writes stay consistent.
Today's teams assemble five or six systems - a vector database, a document store, a graph database, a cache, a queue, and a memory middleware layer - then spend months writing glue code to keep them consistent. Every seam is a place where context leaks.
App state
User session
Vector DB
Embeddings
Graph DB
Relations
Doc store
Documents
Auth
Identity
Data fragments at every system boundary
Agent
Vector DB
Graph DB
Doc store
Auth
Total
WHY VECTOR STORES FAIL
Flat vector stores destroy context
The first generation of AI data infrastructure was built for a single operation: approximate nearest-neighbour search over embeddings. It fails as the primary data layer for agents because of six structural properties.
THE FRAGMENTED MEMORY TAX
Five systems. Five failure modes.
The natural response to vector database limitations has been to add systems. This “frankenstack” approach solves individual capability gaps but introduces systemic problems.
THE READ-THINK-WRITE LOOP
Data platforms answer “what happened.” The context layer answers “what should happen next.”
An AI agent operates through a continuous cycle: perceive the environment, reason over memory, commit an action or observation back to storage. This loop runs in milliseconds, and it never stops.
Modern data platforms - Snowflake, Databricks, BigQuery - are optimised for analytical throughput: answering questions about the past at scale. Agents don't need to analyse the past; they need to act in the present.
This is why the context layer must live in the database, not above it as middleware. Only at the database layer can context be kept consistent, governed, secured, and transactionally unified with the canonical knowledge that grounds it.
EVOLUTION
From metadata to context
WHY THE DATABASE
The context layer must live in the database
WHAT THE THESIS COVERS
COMPETITIVE ANALYSIS
Why alternatives fall short
The thesis examines why each competing approach is architecturally insufficient for production agent systems.
THE THESIS
From object storage to agent memory. A single stack. A single transaction boundary.
MEMORY LIFECYCLE
What to remember. What to forget.
Production memory systems must manage the full lifecycle of knowledge - not just ingestion and retrieval, but also decay and eviction. Infinite memory retention creates retrieval noise, stale fact contamination, and compounding cost.
Some systems approach this with probabilistic decay functions that automatically prune memories based on age and access frequency. This risks discarding information that appears low-value but is contextually critical. A rarely accessed medical allergy is more important than a frequently accessed coffee preference - but a frequency-based decay function treats them inversely.
SurrealDB's approach is deterministic. Facts carry explicit temporal metadata. Queries filter by time range and validity. The application - or a governance policy defined in the schema - decides what is retained and what is evicted, based on business rules rather than probabilistic heuristics.
ATOMIC CONTEXT
Context must be atomic because agents make decisions in real time
The central architectural claim of this thesis is that context for AI agents must be atomic - a single memory is not a collection of pointers across different systems but a unified record within a single transactional boundary.
In SurrealDB, a graph edge is a document. It can hold the weight of a relationship, the timestamp of the last interaction, the vector embedding of the context, and arbitrary metadata - all retrievable in a single query. No amount of orchestration middleware can make multiple databases behave as a single ACID-compliant transactional system.
If the context is inconsistent - if the graph says one thing and the vector store says another - the agent's reasoning is compromised. ACID transactions are the only mechanism that guarantees a consistent view across all data models at query time.

