Skip to main content

Task Storage

ra2a supports multiple storage backends for persisting task state. By default, tasks are stored in-memory and lost on restart.

In-Memory (Default)

No configuration needed — tasks are stored in a DashMap and lost when the server stops:

A2AServerBuilder::new()
.executor(my_agent)
.build()
.serve()
.await?;

PostgreSQL

cargo add ra2a --features postgresql
use ra2a::storage::PostgresTaskStore;

let store = PostgresTaskStore::new("postgres://user:pass@localhost/a2a").await?;

A2AServerBuilder::new()
.executor(my_agent)
.task_store(store)
.build()
.serve()
.await?;

MySQL

cargo add ra2a --features mysql
use ra2a::storage::MysqlTaskStore;

let store = MysqlTaskStore::new("mysql://user:pass@localhost/a2a").await?;

SQLite

cargo add ra2a --features sqlite
use ra2a::storage::SqliteTaskStore;

let store = SqliteTaskStore::new("sqlite://tasks.db").await?;

All SQL Backends

Enable all SQL backends at once:

cargo add ra2a --features sql

Feature Flag Summary

FlagBackendUse case
(default)In-memoryDevelopment, stateless agents
postgresqlPostgreSQLProduction, distributed deployments
mysqlMySQLProduction, existing MySQL infrastructure
sqliteSQLiteSingle-server deployments, edge
sqlAll of the aboveMaximum flexibility

Schema Migration

SQL backends automatically run migrations on startup. No manual schema setup is required.