Skip to content

Commit 46f21e9

Browse files
fix(agent): use Runner.run_streamed() when running the agents (#1257)
1 parent e8a0dd4 commit 46f21e9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

agent/app/agents/manager_agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ async def process_user_request(light: str, maintenance: str) -> str:
8787
# Create a message with user preferences
8888
message = f"I want to buy plants for {light} light and {maintenance} maintenance."
8989

90-
# Run the agent to get recommendations
91-
result = await Runner.run(manager_agent, message)
90+
# Run the agent with streaming to get recommendations
91+
result = Runner.run_streamed(manager_agent, message)
92+
93+
# Consume the stream
94+
async for _ in result.stream_events():
95+
pass
9296

9397
logging.debug(f"manager_agent completed purchase: {result.final_output}")
9498
print(result)

agent/app/agents/plant_expert_agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ async def get_recommendations(light: str, maintenance: str) -> str:
5353
# Create a message with user preferences
5454
msg = f"Reccomend plants for {light} light and {maintenance} maintenance."
5555

56-
# Run the agent
57-
result = await Runner.run(plant_expert_agent, msg)
56+
# Run the agent with streaming
57+
result = Runner.run_streamed(plant_expert_agent, msg)
58+
59+
# Consume the stream
60+
async for _ in result.stream_events():
61+
pass
5862

5963
logging.debug(f"PlantExpertAgent provided recommendations: {result.final_output}")
6064
return str(result.final_output)

0 commit comments

Comments
 (0)