Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions examples/agent_patterns/agents_as_tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio

from agents import Agent, ItemHelpers, MessageOutputItem, Runner, trace
from agents import Agent, ItemHelpers, Runner, trace

"""
This example shows the agents-as-tools pattern. The frontline agent receives a user message and
Expand Down Expand Up @@ -63,9 +63,12 @@ async def main():
orchestrator_result = await Runner.run(orchestrator_agent, msg)

for item in orchestrator_result.new_items:
if isinstance(item, MessageOutputItem):
text = ItemHelpers.text_message_output(item)
if text:
text = ItemHelpers.text_message_output(item)
if text:
if hasattr(item, 'tool_name') and 'translate_to_' in getattr(item, 'tool_name', ''):
lang = item.tool_name.replace("translate_to_", "").capitalize()
print(f" - {lang}: {text}")
else:
print(f" - Translation step: {text}")

synthesizer_result = await Runner.run(
Expand Down
Loading