cleandataengineering.aiAgent Harness, drawn simply
You are here: Tech stack › L5 · State & memory

Agent Harness Tutorial · Tech stack

L5 · State & memory

What is kept, for how long, and for whom. Family: Think · one turn, in order.

AZURE OPTIONSAzure Database for PostgreSQL✓ used: HA, backups, Entra loginCosmos DB· considered: not pickedManaged Redis· considered: optional, caches onlyOUR CHOICEAzure PostgreSQL Flexible ServerB1ms in devpsycopg + pooldriver5 agent tables + DBOSsame databaseOPEN-SOURCE OPTIONSPostgreSQL / Redis containers· considered: not pickedWHO DOES THE WORKAzure gives 40% · we code once 45% · each agent team still does 15%
Dark boxes are what we run. Solid boxes are used or planned; dashed boxes were considered or dropped (crossed). The bar: grey is what Azure gives, dark is what we code once, hatched is what each agent team writes.
Why our choiceOne managed store that also holds DBOS's state and, later, pgvector: no extra infrastructure.
OptionWhere fromVerdictWhy
Azure PostgreSQL Flexible Serverours✓ chosenB1ms in dev
psycopg + poolours✓ chosendriver
5 agent tables + DBOSours✓ chosensame database
Azure Database for PostgreSQLAzure✓ usedHA, backups, Entra login
Cosmos DBAzure· considerednot picked
Managed RedisAzure· consideredoptional, caches only
PostgreSQL / Redis containersopen source· considerednot picked

How it works inside the harness: State & memory.

Compared: Where does conversation state live?

Azure PostgreSQL Flex…AzurechosenCosmos DBAzurefor global scaleAzure Managed RedisAzureoptionalSQLite / file storeopen sourcelocal onlyIn-memory storeourstests only
Dark: what we chose. Crossed and dashed: rejected or not for us. Added here (not a Series table).
OptionFromVerdictHolds hereOne transaction with ledgerFits DBOS and pgvectorHA on AzureWhy
Azure PostgreSQL Flexible ServerAzurechosenstate, ledger, approvals, findingsyesyeszone-redundant HAone store, Entra login, backups
Cosmos DBAzurefor global scalenothing todaywithin one partition onlynomulti-region built inonly for global scale
Azure Managed RedisAzureoptionalcounters and short caches onlynonozone redundancy availablefast, but not the record
SQLite / file storeopen sourcelocal onlyreference agent, on a laptopyes, one processnononesimple local runs
In-memory storeourstests onlytest staten/anononefast, nothing survives a restart
DecisionAll durable state lives in Azure PostgreSQL, because the ledger, outbox and checkpoint commit together and DBOS and pgvector reuse the same database. Cosmos DB would be considered only for global scale, and Redis only for counters and short caches.

How it is done: the real code

Cut from the live repositories each time the site is built, so it always matches what runs.

  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}
  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'