Agents need isolated, persistent state. A shared table with an agent_id column is a workaround. A dedicated database per agent is the architecture. Turso lets you spin up millions of them, each with hard isolation, persistent memory, and vector search built in.
import { createClient } from '@tursodatabase/api';
const turso = createClient({
org: process.env.TURSO_ORG,
token: process.env.TURSO_PLATFORM_TOKEN,
});
// Every agent gets its own isolated workspace
const agentDb = await turso.databases.create(`agent-${agentId}`, {
group: 'production',
schema: 'agent-template',
});
// Persistent memory. Hard isolation. Cost-irrelevant at scale.
Each agent tracks files, stores memories, and logs actions in a store that is its own.
Branching is a metadata-only operation, so an agent can fork its state, try something, and roll back if it fails.
An idle agent database costs only storage. You can run tens of thousands of them without paying for tens of thousands of servers.
Native vector search means embeddings live in the same database as the rest of the agent's state, with no extension and no separate vector store to operate. For on-device agents, that database and its embeddings can sit directly on the device, so retrieval happens without a round-trip to a server.
“Engine Labs cut database costs from $3,000–$5,000 per month on traditional managed Postgres to low hundreds on Turso, while running tens of thousands of isolated agent databases.”
Read the Engine Labs storySpin up your first database in under a minute on the free Starter plan, or fork the open-source Turso Database on GitHub.