Skip to content
NEW BLOG

Using Surrealism to build your own extensions

Read blog

1/2

AI Agents hero illustration

Build context-aware AI agents

Agents fail because of context, not models. SurrealDB + Spectron give AI agents structured context, persistent memory, and transactional consistency in one system.

THE PROBLEM

The context wall

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.

Context leakage

When data flows between separate systems, agents lose context. Relationships, history, and metadata get fragmented.

No atomicity

Without unified transactions, an agent can update memory in one system but fail to update state in another.

Latency spikes

Multi-system pipelines add round trips. Each hop introduces latency that compounds under load.

Operational overhead

Five systems means five failure modes, five monitoring setups, five sets of credentials to manage.

THE SOLUTION

The read-think-write loop

Agents operate in a continuous cycle: read context, reason over it, and write results back. The context layer keeps the entire loop inside one transactional system.

Read

Query structured data, traverse knowledge graphs, perform vector similarity search, and retrieve temporal facts - all in a single SurrealQL statement.

Think

The agent reasons over rich, multi-model context. Documents, relationships, embeddings, and history arrive together - no stitching from separate systems.

Write

Persist decisions, update entities, append new facts, and trigger downstream events - all within a single ACID transaction.

CONTEXT ENGINEERING

Context engineering in one query

SurrealQL lets you combine graph traversal, vector similarity, structured filters, and temporal queries in a single statement. One round trip gives the agent everything it needs.

1-- Context engineering: combine graph, vector, and temporal data
2LET $user = user:jaime;
3LET $query_vec = fn::embed("What products does this user like?");
4
5SELECT
6 ->purchased->product AS purchase_history,
7 ->reviewed->product[WHERE vector::similarity::cosine(embedding, $query_vec) > 0.8] AS relevant_products,
8 ->preferences[WHERE valid_at <= time::now()] AS current_preferences
9FROM ONLY $user;

MULTI-AGENT

Multi-agent coordination

Multiple agents share the same knowledge graph and memory. Coordination happens through shared context with ACID guarantees - no message passing, no race conditions.

Shared memory

Agents read from and write to the same Spectron memory graph. Knowledge accumulates across the team.

ACID consistency

Concurrent writes from multiple agents are serialised. No conflicts, no lost updates.

Event-driven handoffs

Live queries and events trigger downstream agents when relevant data changes.

Unified permissions

RBAC and record-level permissions apply consistently across all agents accessing the system.

THE STACK

SurrealDB + Spectron

SurrealDB provides the multi-model database for structured context. Spectron provides persistent memory for AI agents. Together, they form the context layer - one stack, one transaction boundary, one permission model.

WORKS WITH YOUR FRAMEWORK

The context layer beneath your orchestrator

LangGraph, CrewAI, and AutoGen orchestrate agent logic - the control flow. SurrealDB provides the persistent context layer beneath - the data, the memory, the knowledge graph. They are complementary. Connect through MCP, SDKs, or direct API calls.

LangChain & LangGraph

Use SurrealDB as the persistent context store for LangGraph agents. Memory, state, and knowledge in one system.

CrewAI & AutoGen

Multi-agent frameworks get shared memory and transactional coordination through SurrealDB and Spectron.

MCP native

Any MCP-compatible client connects to the full platform - data, memory, and infrastructure - through standard tool calls.

Direct SDKs

Official SDKs for Python, JavaScript, Rust, Go, Java, .NET, and PHP. Build custom integrations with any framework.

GET STARTED

Build context-aware AI agents

The context layer for AI agents. Structured context, persistent memory, elastic storage. One stack.