Handle multi-turn conversations in async agents with task-based state management. Each task maintains its own conversation history automatically.
- How tasks maintain conversation state across multiple exchanges
- Difference between sync and async multiturn patterns
- Building stateful conversational agents with minimal code
- Development environment set up (see main repo README)
- Backend services running:
make devfrom repository root - Understanding of basic async agents (see 000_hello_acp)
cd examples/tutorials/10_async/00_base/010_multiturn
uv run agentex agents run --manifest manifest.yamlUnlike sync agents where you manually track conversation history, async agents automatically maintain state within each task:
@app.on_task_event_send()
async def on_task_event_send(event_send: TaskEventSendInput):
# The task's messages list automatically includes all previous exchanges
messages = event_send.task.messages
# No need to manually pass history - it's already there!
response = await openai_client.chat.completions.create(
model="gpt-4o-mini",
messages=messages
)
return {"content": response.choices[0].message.content}- Start the agent with the command above
- Open the web UI or use the notebook to create a task
- Send multiple messages in the same task:
- "What's 25 + 17?"
- "What was that number again?"
- "Multiply it by 2"
- Notice the agent remembers context from previous exchanges
- Conversational agents that need memory across exchanges
- Chat interfaces where users ask follow-up questions
- Agents that build context over time within a session
Task-based state management eliminates the complexity of manually tracking conversation history. The AgentEx platform handles state persistence automatically, making it easier to build stateful agents without custom session management code.
Comparison: In the sync version (00_sync/010_multiturn), you manually manage conversation history. Here, the task object does it for you.
Next: 020_streaming - Add real-time streaming responses