cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › State & memory

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
The bottom row is the five kinds of memory. Each one opens its page.
Kind of memoryKept inHow long
This turn: messages, tool calls, raw resultsthe process's memoryone turn, never saved
The conversationagent_state.checkpoints30 days
What was already doneagent_state.requests (the ledger)the row expires after 600 s in flight
Work waiting for a personagent_state.approvals, escalations, and DBOS's tables24 h for an approval
Who you arethe token in the browser; refresh token encrypted in agent_state.sessions1 h; 12 h unused
Policies and claimsthe claims system's own databasethe system of record
Long-term memory across conversationsnot 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