Enable
PassWithConversation with a conversation.Config:
| Field | Description |
|---|---|
Conversation | Backend implementing interfaces.Conversation |
Size | Max past messages loaded for the LLM — defaults to 20 when zero |
SaveOnIteration | Persist after each tool round — useful when external consumers need live updates during multi-step runs |
conversation.DefaultConfig(conv) for SDK defaults with no overrides.
Conversation ID
When conversation is enabled, pass the same session ID on every call to share history:Backends
| Backend | Package | Use case |
|---|---|---|
| In-memory | pkg/conversation/inmem | Single process — agent and worker together |
| Redis | pkg/conversation/redis | Remote workers or split client/worker across processes |
| Custom | Implement interfaces.Conversation | Your own store or distributed backend |
Remote workers
Use Redis on both the agent and worker processes. Pass the sameconversation.Config to NewAgent and NewAgentWorker. Set SaveOnIteration: true on the worker if external consumers need live history mid-run. See Worker Separation for the full setup.
Lifecycle
You own the conversation store. CallClear(ctx, id) when ending a session — the agent never clears history for you.
With
SaveOnIteration: true on the worker, history is written after each tool round so external consumers can read it mid-run. Without it, history is written only when the run completes. Set it on the worker, not the agent.Custom backend
Implementinterfaces.Conversation:
IsDistributed() to true for any backend that can be shared across processes. The SDK uses this to validate compatibility with remote-worker deployments. Pass the implementation in conversation.Config.Conversation.
Example
Conversation
Redis-backed multi-turn history
Stream + Conversation
Streaming with persisted history
Related
Memory
Long-term facts across separate runs
Worker Separation
Redis conversation with remote workers
Streaming
Stream with conversation options
Configuration
WithConversation reference