Skip to main content

Quickstart: OpenAI Agents Session Management

Coming Soon

This tutorial is under development. Check back soon!

What You'll Build

An OpenAI agent with persistent conversation memory that:

  • Remembers context — Previous messages persist across requests
  • Survives restarts — Memory stored in Dapr state, not in-process
  • Scales horizontally — Any instance can serve any session

Prerequisites

Architecture

┌──────────────┐         ┌──────────────┐
│ Request │ │ Request │
│ Session: A │ │ Session: A │
└──────┬───────┘ └──────┬───────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ OpenAI │ │ OpenAI │
│ Instance 1 │ │ Instance 2 │
└──────┬───────┘ └──────┬───────┘
│ │
└────────┬───────────────┘

┌────────────────┐
│ Dapr State │
│ (Session A) │
└────────────────┘

Both instances read/write to the same session state. The user gets consistent memory regardless of which instance handles the request.

Key Concepts

ConceptDescription
Session IDUnique identifier for a conversation thread
State StoreDapr component that persists session data (Redis, PostgreSQL, etc.)
Memory PatternStore/retrieve conversation history before each LLM call
TTLOptional expiration for inactive sessions