You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Has anyone been able to get an Agent Graph to stream the response back?
We are implementing a workflow approach and explored the task, workflow and graph approaches, but we have not been able to get a graph to stream back as a graph doesn't seem to come with the same streaming ability as an Agent?
The reason we are looking at tasks and Graphs is to setup parallel processing of some agents, and then aggregating to a final node which we want to be the one which streams a response back.
e.g. The example posted on Strands 1.0 documentation for a graph is below.
fromstrandsimportAgentfromstrands.multiagentimportGraphBuilder, Swarm# Create a swarm of research agentsresearch_agents= [
Agent(name="medical_researcher", system_prompt="You are a medical research specialist..."),
Agent(name="technology_researcher", system_prompt="You are a technology research specialist..."),
Agent(name="economic_researcher", system_prompt="You are an economic research specialist...")
]
research_swarm=Swarm(research_agents)
# Create a single agent node tooanalyst=Agent(system_prompt="Analyze the provided research.")
# Create a graph with the swarm as a nodebuilder=GraphBuilder()
builder.add_node(research_swarm, "research_team")
builder.add_node(analyst, "analysis")
builder.add_edge("research_team", "analysis")
graph=builder.build()
result=graph("Research the impact of AI on healthcare and create a comprehensive report")
# Access the resultsprint(f"\n{result}")
but graph doesn't expose the same stream_async as an Agent.
importasynciofromstrandsimportAgentfromstrands_toolsimportcalculator# Initialize our agent without a callback handleragent=Agent(
tools=[calculator],
callback_handler=None
)
# Async function that iterators over streamed agent eventsasyncdefprocess_streaming_response():
agent_stream=agent.stream_async("Calculate 2+2")
asyncforeventinagent_stream:
print(event)
# Run the agentasyncio.run(process_streaming_response())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Has anyone been able to get an Agent Graph to stream the response back?
We are implementing a workflow approach and explored the task, workflow and graph approaches, but we have not been able to get a graph to stream back as a graph doesn't seem to come with the same streaming ability as an Agent?
The reason we are looking at tasks and Graphs is to setup parallel processing of some agents, and then aggregating to a final node which we want to be the one which streams a response back.
e.g. The example posted on Strands 1.0 documentation for a graph is below.
but graph doesn't expose the same stream_async as an Agent.
Any suggestions would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions