Skip to content

Python Strands Agent to A2A Agent

The connection generator can connect your Python Strands Agent to a remote A2A agent — either TypeScript or Python — so your agent can delegate to another agent as a tool.

The generator sets up all the necessary wiring so your agent can discover and invoke the remote A2A agent, both when deployed to AWS (via Bedrock AgentCore) and when running locally.

Before using this generator, ensure you have:

  1. A Python project with a Strands Agent component (any protocol)
  2. A project with a Strands Agent component generated with --protocol=A2A and --auth=IAM (either ts#strands-agent or py#strands-agent)
  3. Both components created with computeType: BedrockAgentCoreRuntime
  1. Install the Nx Console VSCode Plugin if you haven't already
  2. Open the Nx Console in VSCode
  3. Click Generate (UI) in the "Common Nx Commands" section
  4. Search for @aws/nx-plugin - connection
  5. Fill in the required parameters
    • Click Generate

    Select your host agent project as the source and your A2A agent project as the target. If your projects contain multiple components, specify the sourceComponent and targetComponent options to disambiguate.

    Parameter Type Default Description
    sourceProject Required string - The source project
    targetProject Required string - The target project to connect to
    sourceComponent string - The source component to connect from (component name, path relative to source project root, or generator id). Use '.' to explicitly select the project as the source.
    targetComponent string - The target component to connect to (component name, path relative to target project root, or generator id). Use '.' to explicitly select the project as the target.

    The generator creates a shared agent_connection Python project at packages/common/agent_connection/ (if it doesn’t already exist). Per-connection client modules are generated into this shared project:

    • Directorypackages/common/agent_connection
      • Directory<scope>_agent_connection
        • __init__.py Re-exports per-connection clients
        • Directorycore
          • agentcore_a2a_client.py Core AgentCore A2A client with SigV4 authentication
        • Directoryapp
          • <target_agent_name>_client.py Per-connection client for each A2A agent

    Additionally, the generator:

    • Transforms your agent’s agent.py to register the remote A2A agent as a tool using @tool
    • Adds the agent_connection project as a workspace dependency of your agent project
    • Updates the agent’s serve-local target to depend on the target agent’s serve-local target

    The generator transforms your agent’s agent.py to wrap the remote A2A agent as a tool:

    packages/my-project/my_module/agent/agent.py
    from contextlib import contextmanager
    from strands import Agent, tool
    from my_scope_agent_connection import RemoteAgentClient
    @contextmanager
    def get_agent(session_id: str):
    remote_agent = RemoteAgentClient.create(session_id=session_id)
    @tool
    def ask_remote_agent(prompt: str) -> str:
    """Delegate a question to the remote RemoteAgent A2A agent and return its reply."""
    return str(remote_agent(prompt))
    yield Agent(
    system_prompt="...",
    tools=[ask_remote_agent],
    )

    The session_id parameter is plumbed through from the caller, ensuring consistency for Bedrock AgentCore Observability.

    Under the hood, RemoteAgentClient.create(session_id=...) returns a Strands A2AAgent configured with an httpx.AsyncClient that signs requests with SigV4 when deployed to AWS, and a plain http://localhost:<port>/ endpoint when SERVE_LOCAL=true.

    After running the connection generator, you need to grant the host agent permission to invoke the remote A2A agent.

    packages/infra/src/stacks/application-stack.ts
    const remoteAgent = new RemoteAgent(this, 'RemoteAgent');
    const myAgent = new MyAgent(this, 'MyAgent');
    // Grant the host agent permission to invoke the remote A2A agent
    remoteAgent.grantInvokeAccess(myAgent);

    grantInvokeAccess on an A2A agent wires up both bedrock-agentcore:InvokeAgentRuntime and bedrock-agentcore:GetAgentCard — the A2A client needs both to fetch the agent card and send messages.

    The remote agent’s AgentCore runtime ARN is automatically registered in the agentcore namespace of Runtime Configuration by the generated CDK construct, so the host agent can discover it at runtime.

    The generator configures the host agent’s serve-local target to:

    1. Start the connected A2A agent(s) automatically
    2. Set SERVE_LOCAL=true so the generated client connects directly to http://localhost:<port>/ instead of AgentCore

    Run the agent locally with:

    Terminal window
    pnpm nx <agent-name>-serve-local <project-name>

    This will start both the host agent and all connected A2A agents, with the host agent calling the remote agents over plain HTTP on their assigned local ports.