|
1 |
| -from __future__ import annotations |
| 1 | +from __future__ import annotations as _annotations |
2 | 2 |
|
3 | 3 | import asyncio
|
4 | 4 | import random
|
5 | 5 | import uuid
|
6 | 6 |
|
7 | 7 | from pydantic import BaseModel
|
8 | 8 |
|
9 |
| -from src.agents import ( |
| 9 | +from agents import ( |
10 | 10 | Agent,
|
11 | 11 | HandoffOutputItem,
|
12 | 12 | ItemHelpers,
|
|
22 | 22 | handoff,
|
23 | 23 | trace,
|
24 | 24 | )
|
25 |
| -from src.agents.extensions.handoff_prompt import RECOMMENDED_PROMPT_PREFIX |
| 25 | +from agents.extensions.handoff_prompt import RECOMMENDED_PROMPT_PREFIX |
26 | 26 |
|
27 | 27 | ### CONTEXT
|
28 | 28 |
|
@@ -162,20 +162,15 @@ async def main():
|
162 | 162 | for new_item in result.new_items:
|
163 | 163 | agent_name = new_item.agent.name
|
164 | 164 | if isinstance(new_item, MessageOutputItem):
|
165 |
| - # In tool_choice="required" scenarios, the agent won't produce bare messages; |
166 |
| - # instead it will call `respond_to_user`. But if the example is run without |
167 |
| - # requiring tool_choice, this branch will handle direct messages. |
168 | 165 | print(f"{agent_name}: {ItemHelpers.text_message_output(new_item)}")
|
169 | 166 | elif isinstance(new_item, HandoffOutputItem):
|
170 | 167 | print(
|
171 | 168 | f"Handed off from {new_item.source_agent.name} to {new_item.target_agent.name}"
|
172 | 169 | )
|
173 | 170 | elif isinstance(new_item, ToolCallItem):
|
174 |
| - # Stash the name of the tool call so we can treat respond_to_user specially |
175 | 171 | last_tool_name = getattr(new_item.raw_item, "name", None)
|
176 | 172 | print(f"{agent_name} called tool:{f' {last_tool_name}' if last_tool_name else ''}")
|
177 | 173 | elif isinstance(new_item, ToolCallOutputItem):
|
178 |
| - # If the tool call was respond_to_user, treat its output as the message to display. |
179 | 174 | if last_tool_name == "respond_to_user":
|
180 | 175 | print(f"{agent_name}: {new_item.output}")
|
181 | 176 | else:
|
|
0 commit comments