Guides  /  State and memory

Where should an agent memory live, and what does it cost per turn?

Answer

Every agent turn reads what the agent already knows and writes what it learned. Whether that read crosses a network sets the floor on how fast a turn can finish.

Akka holds agent state in the runtime that executes the agent, replicated across nodes. Reads take single-digit milliseconds and no separate store has to be provisioned, scaled or failed over.

The mechanism

The read path decides the floor.

An agent turn is a sequence of dependent steps. The agent reads context, calls a model, and writes what changed, often several times before producing an answer. Every read and write sits on the path to the response, so their latency multiplies by the number of steps.

Placing that state in an external store adds two network round trips to every turn, and adds a second system with its own capacity planning, failover, and backup schedule. Holding it in the runtime removes the hop and folds durability into replication that already exists for the agent.

MEMORY IN AN EXTERNAL STOREagent turnreadwritestorea network round trip on each read and writeand its own capacity, failover and backupMEMORY IN THE RUNTIMEagent turn and its statesame process, replicated across nodesno network hop on the read pathdurability from replication
What the choice sets

Latency is the cost you see first.

Turn latencyRound trips to an external store are paid on every read and every write, and a multi-step turn pays them repeatedly.
Failure surfaceAn external store is a second thing that can be unavailable while the agent is up, and its outage looks like an agent fault.
Operational loadCapacity, replication, backup and patching for the store belong to whoever provisioned it.
CostPer-query pricing scales with turns rather than with users, and a chatty agent multiplies it.
What this changes

Latency budget returns to the model call.

A user-facing agent has a total budget before the interaction feels slow. The model call consumes most of it, so the remainder decides how many steps the agent can take before the response arrives.

Swiggy cut prediction latency from 144ms to 71ms while holding 5,000 predictions a second on a single model, and the reduction came from removing repeated work on the path.

Questions

Related questions.

Does the state survive a restart?

Durable state is written to an event journal as it changes and replicated across nodes, so a restart replays it.

What about state larger than memory?

State is sharded across the cluster, so capacity grows with the cluster. A single agent instance holds only its own state.

Can an agent still use a vector database?

Retrieval from a vector store is a tool call for knowledge the agent looks up. The state in this guide is what the agent itself accumulated, which is read and written on every turn.

What happens across regions?

State is replicated active-active, so a region loss recovers in under a minute with no committed writes lost.

On Akka. Durable, in-memory, sharded state is described in the Akka SDK documentation. Customer figures. Swiggy latency results were published by Swiggy engineering.