Skip to content

[FEATURE] Agent Graph to allow streamed response #608

@flowconic

Description

@flowconic

Problem Statement

I would like Strands to add streaming support to an agent graph so that I can enable an increased user-experience on the receiving end while still getting the power of agent graphs conditions and parallel processing.

Proposed Solution

Extend the graph with an stream_async in the same way as an agent has it today.
e.g. something like

from strands import Agent
from strands.multiagent import GraphBuilder, Swarm

# Create a swarm of research agents
research_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 too
analyst = Agent(system_prompt="Analyze the provided research.")

# Create a graph with the swarm as a node
builder = GraphBuilder()
builder.add_node(research_swarm, "research_team")
builder.add_node(analyst, "analysis")
builder.add_edge("research_team", "analysis")

graph = builder.build()


#NOTE the proposed "stream_async"
result = graph.stream_async("Research the impact of AI on healthcare and create a comprehensive report")

Use Case

When needing to use the power of an agent graph in a more controlled workflow approach, but when still having an end user on the other side where we want to have a higher degree of user experience.
Example Use case: Take a text (e.g. prompt to research, text to summarise etc) and then e.g.

  1. Validate text against criteria. Only continue if valid
  2. Run below parallel
  • Extract e.g. actions from a text
  • Extract decisions from a text
  • Extract summary overview from a text
  • Look up (http) links for research in parallel
  • Gather results from previous steps in the agent graph
  • Validate certain criteria or quality

and then have the final "node" in the graph with the ability to stream back the response to a real user

Alternatives Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

area-multiagentMulti-agent relatedenhancementNew feature or requestrefinedIssue is discussed with the team and the team has come to an effort estimate consensus

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions