Agent Harness Tutorial · End to end · Zoom level 1
State and memory
The harness server can be switched off between two messages, and Azure does exactly that when it is quiet. So the server keeps nothing that matters. Every turn loads what it needs from PostgreSQL at the start and writes it back at the end.
Goes inRohan's conversation id, from his browser
What happensLoad the newest checkpoint; during the turn write ledger rows; at the end save a new checkpoint
Comes outA conversation that survives any restart
| Kind of memory | Kept in | How long |
|---|---|---|
| This turn: messages, tool calls, raw results | the process's memory | one turn, never saved |
| The conversation | agent_state.checkpoints | 30 days |
| What was already done | agent_state.requests (the ledger) | the row expires after 600 s in flight |
| Work waiting for a person | agent_state.approvals, escalations, and DBOS's tables | 24 h for an approval |
| Who you are | the token in the browser; refresh token encrypted in agent_state.sessions | 1 h; 12 h unused |
| Policies and claims | the claims system's own database | the system of record |
| Long-term memory across conversations | not built yet |
Two databases, two logins. The agent's login cannot even connect to the claims database. The claims system's login may read exactly one agent table: approvals, to check a payout was really approved.
Want every detail? The long version is in the Series: state and memory in full.
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
config/azure.yaml:36The state port on Azure: PostgreSQL, secrets from Key Vault state:
adapter: azure-postgresql-flexible
url: {key_vault: agent-database-url}
# A2: the sign-in's refresh tokens (agent_state.sessions), encrypted with a
# key derived from this secret; azd generates it and Bicep writes it.
session_key: {key_vault: agent-session-key}
records:
adapter: postgres
url: {key_vault: agent-database-url}infra/modules/postgres.bicep:84infra/modules/postgres.bicep: the server sku: {
name: 'Standard_B1ms'
tier: 'Burstable'
}
properties: {
version: '16'
administratorLogin: administratorLogin
administratorLoginPassword: administratorPassword
storage: {
storageSizeGB: 32
autoGrow: 'Disabled'
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
highAvailability: {
mode: 'Disabled'
}
authConfig: {
activeDirectoryAuth: 'Enabled'
passwordAuth: 'Enabled'Tech choices (what we chose, Azure and open-source options): L5 · State & memory
Look inside
This turn, in memoryWhat lives only for one turn, and why it is thrown away.The tablesFive agent tables, five claims tables, and DBOS's own.Inside a checkpointOne row per turn: the text, a few notes, and what is pending.Which step touches which tableRead at the start, ledger in the middle, save at the end.