Skip to content

Conversation

@mkmeral
Copy link
Contributor

@mkmeral mkmeral commented Feb 2, 2026

Description

Graph currently only accepts Agent | MultiAgentBase as node executors, preventing A2AAgent and other AgentBase implementations from being used in graph workflows. Since A2AAgent implements the AgentBase protocol (not the concrete Agent class), users cannot build graphs that orchestrate remote A2A agents alongside local agents.

This change updates Graph to accept AgentBase | MultiAgentBase, enabling any protocol-compliant agent implementation to participate in graph-based multi-agent workflows.

Related Issues

Resolves: #907

Documentation PR

N/A - no new public API, just expanded type acceptance

Type of Change

New feature

Public API Changes

GraphBuilder.add_node() and GraphNode.executor now accept AgentBase implementations:

# Before: A2AAgent couldn't be used in graphs
from strands.agent.a2a_agent import A2AAgent
from strands.multiagent.graph import GraphBuilder

a2a_agent = A2AAgent(endpoint="http://remote-agent:9000")
builder = GraphBuilder()
builder.add_node(a2a_agent, "remote")  # TypeError or unsupported

# After: A2AAgent works as a graph node
builder = GraphBuilder()
builder.add_node(a2a_agent, "remote")
builder.add_node(local_agent, "local")
builder.add_edge("remote", "local")
graph = builder.build()
result = await graph.invoke_async("Process this request")

Additionally, Agent now explicitly extends AgentBase for compile-time protocol verification.

Testing

  • Unit test: test_graph_with_agentbase_implementation - verifies custom AgentBase implementations work with Graph

  • Integration test: test_graph_with_a2a_agent_and_regular_agent - verifies real A2AAgent + Agent in Graph workflow

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Enable Graph to accept any AgentBase implementation as a node, allowing
A2AAgent and other AgentBase implementations to be used in graph workflows.

Changes:
- Make Agent explicitly extend AgentBase protocol
- Update GraphNode.executor type to AgentBase | MultiAgentBase
- Consolidate Agent handling into single AgentBase branch in _execute_node

Closes strands-agents#907 (partial - enables A2AAgent in graphs)
@mkmeral mkmeral marked this pull request as ready for review February 2, 2026 20:11
@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/multiagent/graph.py 91.66% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@mkmeral
Copy link
Contributor Author

mkmeral commented Feb 2, 2026

/strands review

1 similar comment
@mkmeral
Copy link
Contributor Author

mkmeral commented Feb 3, 2026

/strands review

@github-actions github-actions bot added the size/m label Feb 3, 2026
@github-actions github-actions bot added size/m and removed size/m labels Feb 3, 2026
@github-actions github-actions bot added size/m and removed size/m labels Feb 3, 2026
@mkmeral mkmeral enabled auto-merge (squash) February 3, 2026 22:32
agent.messages = node_context["messages"]
agent.state = AgentState(node_context["state"])
agent._interrupt_state = _InterruptState.from_dict(node_context["interrupt_state"])
# Restore Agent-specific state for interrupt resumption
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we could now remove the MultiAgentBase instance check directly above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] A2AAgent: Create a new A2AAgent class

2 participants