|
1 | 1 | # [Sync] Multiturn |
2 | 2 |
|
3 | | -Handle multi-turn conversations in synchronous agents by manually maintaining conversation history and context between messages. |
| 3 | +This tutorial demonstrates how to handle multiturn conversations in AgentEx agents using the Agent 2 Client Protocol (ACP). |
4 | 4 |
|
5 | | -## What You'll Learn |
6 | | -- How to handle conversation history in sync agents |
7 | | -- Building context from previous messages |
8 | | -- The limitations of stateless multiturn patterns |
| 5 | +## Official Documentation |
9 | 6 |
|
10 | | -## Prerequisites |
11 | | -- Development environment set up (see [main repo README](https://github.com/scaleapi/scale-agentex)) |
12 | | -- Backend services running: `make dev` from repository root |
13 | | -- Understanding of basic sync agents (see [000_hello_acp](../000_hello_acp/)) |
14 | | - |
15 | | -## Quick Start |
16 | | - |
17 | | -```bash |
18 | | -cd examples/tutorials/00_sync/010_multiturn |
19 | | -uv run agentex agents run --manifest manifest.yaml |
20 | | -``` |
21 | | - |
22 | | -## Key Pattern |
23 | | - |
24 | | -Sync agents are stateless by default. To handle multi-turn conversations, you need to: |
25 | | -1. Accept conversation history in the request |
26 | | -2. Maintain context across messages |
27 | | -3. Return responses that build on previous exchanges |
28 | | - |
29 | | -```python |
30 | | -@acp.on_message_send |
31 | | -async def handle_message_send(params: SendMessageParams): |
32 | | - # Accept conversation history from client |
33 | | - history = params.conversation_history |
34 | | - |
35 | | - # Build context from history |
36 | | - context = build_context(history) |
37 | | - |
38 | | - # Generate response considering full context |
39 | | - response = generate_response(params.content, context) |
40 | | - |
41 | | - return TextContent(author="agent", content=response) |
42 | | -``` |
43 | | - |
44 | | -The handler accepts history, builds context, and returns responses that reference previous exchanges. |
45 | | - |
46 | | -## When to Use |
47 | | -- Simple chatbots that need conversation memory |
48 | | -- When client can maintain and send conversation history |
49 | | -- Quick prototypes before building full agentic agents |
50 | | - |
51 | | -## Why This Matters |
52 | | -While sync agents can handle conversations, you're responsible for managing state on the client side. This becomes complex quickly. For production conversational agents, consider agentic agents ([10_agentic/00_base/010_multiturn](../../10_agentic/00_base/010_multiturn/)) where the platform manages state automatically. |
53 | | - |
54 | | -**Next:** [020_streaming](../020_streaming/) - Stream responses in real-time |
| 7 | +[010 Multiturn](https://dev.agentex.scale.com/docs/tutorials/sync/010_multiturn) |
0 commit comments