I have been searching all day to get this to work. So let me try to explain.
1: I want to run a team.
2: I want the team streaming events, to update my frontend. This works perfectly and always (TeamRunResponseEvent).
3: I also want the events coming from the member agents. Those are RunResponseEvent, I had this working, but for the life of me I can’t figure out how.
reddit_researcher = Agent(
name="Reddit Researcher",
role="Research a topic on Reddit",
model=OpenAIChat(id="gpt-4o"),
tools=[DuckDuckGoTools()],
add_name_to_instructions=True,
instructions=dedent("""
You are a Reddit researcher.
You will be given a topic to research on Reddit.
You will need to find the most relevant posts on Reddit.
"""),
)
agent_team = Team(
name="Discussion Team",
mode="collaborate",
model=OpenAIChat("gpt-4o"),
members=[
reddit_researcher,
# hackernews_researcher,
# academic_paper_researcher,
# twitter_researcher,
],
instructions=[
"You are a discussion master.",
"You have to stop the discussion when you think the team has reached a consensus.",
],
success_criteria="The team has reached a consensus.",
enable_agentic_context=True,
show_tool_calls=True,
markdown=True,
show_members_responses=True,
)
Show member responses appears to be the property to have this working.
if __name__ == "__main__":
async def debug_stream():
stream = await agent_team.arun(
message="Start the discussion on the topic: 'What is the best way to learn to code?'",
stream=True,
)
async for step in stream:
print(f"🟡 EVENT: {step.event} → {type(step).__name__}")
asyncio.run(debug_stream())
But I am getting absolutely nothing but TeamRunResponseEvent and ToolCallCompleted (I believe)… I really want to have the RunResponseEvent as well from the agent. I really believe it’s possible, but I have no clue as to how.
More details:
The reddit agent is called, and it will give a response, the only issue is that I cannot capture it’s streaming events.
Dus anyone know. Thanks in advance!