# AX-SYS-16: Persist state across multi-step workflows

> Memory and state · advanced · AX-SYS-16

Give long-running, multi-step agent tasks stable identifiers and durable state, so progress survives retries, scaling, and reconnection.

## Why

Stateful sessions that collide with load balancers lose work mid-task. Anthropic's guidance on long-running agent harnesses is explicit: progress held only in an in-memory session is lost on any retry, scaling event, or reconnection. The MCP Tasks specification formalizes this with a defined lifecycle (submitted → working → input-required → completed/failed) and stable task IDs. The 12-Factor Agents framework calls for stateless reducers with durable external state — the agent's code should be able to restart from any point given the stored task state.

## Do

Use durable task IDs and resumable state.

## Don't

Hold critical state only in a sticky session.

## Artifact

```json
{
  "task_id": "task_88a",
  "status": "running",
  "step": 3,
  "of": 5,
  "resumable": true,
  "resume_token": "rt_...",
  "updated_at": "2026-06-04T12:00:00Z"
}
```

## Citations

1. [Anthropic — Effective Harnesses for Long-Running Agents](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents) — Long-running, multi-context-window workflows require durable task identifiers and resumable state; progress held only in an in-memory session is lost on any retry, scaling event, or reconnection
2. [MCP Specification 2025-11-25 — Tasks](https://modelcontextprotocol.io/specification/2025-11-25) — MCP Tasks lifecycle defines submitted, working, input-required, completed, canceled, and failed states with stable task IDs for durable multi-step agent workflows
3. [12-Factor Agents — Stateless Design](https://github.com/humanlayer/12-factor-agents) — Agents should be designed as stateless reducers — each operation processes inputs and produces outputs independently — with durable external state rather than sticky in-process sessions

---
Source: Agent Experience Principles (axprinciples.com)