Skip to content

Commit 40a65dc

Browse files
committed
pros/cons
Signed-off-by: Filinto Duran <[email protected]>
1 parent 23136fa commit 40a65dc

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

docs/sessions/dapr_session.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,34 @@ The `DaprSession` class integrates the OpenAI Agents SDK with Dapr's state manag
1717

1818
## When to use DaprSession
1919

20-
Choose `DaprSession` when you need:
21-
22-
- **Multi-instance deployment**: Your agents run across multiple servers and need shared state
23-
- **Backend flexibility**: You want to switch between Redis, PostgreSQL, MongoDB, etc. without code changes
24-
- **Enterprise features**: TTL, encryption, consistency guarantees, and automatic retries are critical
25-
- **Platform standardization**: Your team already uses Dapr for other services
26-
- **Microservices architecture**: Your agents are part of a larger Dapr-enabled ecosystem
27-
28-
**Not recommended for**:
29-
- Single-instance applications (use `SQLiteSession` instead)
30-
- Simple prototypes (use `Session` instead)
31-
- Applications without Dapr infrastructure
20+
### Ideal use cases
21+
22+
Choose `DaprSession` when you have:
23+
24+
- **Horizontally scaled deployments**: Multiple agent instances behind a load balancer need to share conversation state
25+
- *Example*: A customer service chatbot deployed across 10+ Kubernetes pods
26+
- **Multi-region requirements**: Your agents run in different geographic regions and need consistent state
27+
- *Example*: Global support system where users can be served from any region
28+
- **Existing Dapr adoption**: Your team already uses Dapr for other microservices
29+
- *Example*: Your organization has standardized on Dapr for service mesh, pub/sub, and state management
30+
- **Backend flexibility requirements**: You need to switch state stores without redeploying code
31+
- *Example*: Starting with Redis in dev, moving to Cosmos DB in production
32+
- **Enterprise governance**: Platform teams need centralized control over state management policies
33+
- *Example*: Security requires encryption, TTL, and audit logging configured at the infrastructure level
34+
35+
### When to consider alternatives
36+
37+
**Use `SQLiteSession` instead if**:
38+
- Your agent runs as a single instance (desktop app, CLI tool, personal assistant)
39+
- You want zero external dependencies
40+
41+
**Use `Session` (in-memory) instead if**:
42+
- You're building a quick prototype or demo
43+
- Sessions are short-lived and losing state on restart is acceptable
44+
45+
### The trade-off
46+
47+
`DaprSession` adds operational complexity (running Dapr sidecars, managing components) in exchange for production-grade features, flexibility and governance. Choose it when that trade-off makes sense for your deployment scale and requirements.
3248

3349
## Installation
3450

0 commit comments

Comments
 (0)