- A “customer” agent, who has been assigned a random department they need to reach but is instructed not to directly state it.
- A “trainee” customer service representative, who must figure out the correct department based on the customer’s story.
Code
Key points
- Multi-agent interaction: This example showcases how to orchestrate a conversation between two AI agents, each with distinct roles and objectives.
-
Parent task as control flow: The
main_task
serves dual purposes - it represents the overall objective and acts as a control mechanism for the conversation loop. Thewhile main_task.is_incomplete()
construct creates a flexible, AI-driven loop that continues until the trainee decides to route the call. - Explicit turn-taking: Instead of using ControlFlow’s built-in turn strategies, this example manually alternates between the customer and trainee agents. This provides fine-grained control over the conversation flow and allows for specific instructions to be given to each agent on each turn.
-
Task-specific tools: The trainee is given access to the
main_task
’s success tool, allowing them to mark the overall task as complete when they’re ready to route the call, even though that task isn’t currently active. This demonstrates how tools can be used to give agents control over task state.
Further reading
- For more details on creating and managing tasks, see the Tasks documentation.
- To learn more about agents and their capabilities, check out the Agents guide.
- For information on how ControlFlow manages conversations and context, refer to the Message History guide.