TypeScript Strands Agent to A2A Agent
The connection generator can connect your TypeScript 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.
Prerequisites
Section titled “Prerequisites”Before using this generator, ensure you have:
- A TypeScript project with a Strands Agent component (any protocol)
- A project with a Strands Agent component generated with
--protocol=A2Aand--auth=IAM(eitherts#strands-agentorpy#strands-agent) - Both components created with
computeType: BedrockAgentCoreRuntime
Run the Generator
Section titled “Run the Generator”- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - connection - Fill in the required parameters
- Click
Generate
pnpm nx g @aws/nx-plugin:connectionyarn nx g @aws/nx-plugin:connectionnpx nx g @aws/nx-plugin:connectionbunx nx g @aws/nx-plugin:connectionYou can also perform a dry-run to see what files would be changed
pnpm nx g @aws/nx-plugin:connection --dry-runyarn nx g @aws/nx-plugin:connection --dry-runnpx nx g @aws/nx-plugin:connection --dry-runbunx nx g @aws/nx-plugin:connection --dry-runSelect 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.
Options
Section titled “Options”| 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. |
Generator Output
Section titled “Generator Output”The generator creates a shared agent-connection package and modifies your agent code:
Directorypackages/common/agent-connection
Directorysrc
Directoryapp
- <target-agent-name>-client.ts High-level client for the connected A2A agent
Directorycore
- agentcore-a2a-client.ts Low-level AgentCore A2A client with SigV4 authentication
- index.ts Exports all clients
- project.json
- tsconfig.json
Additionally, it:
- Transforms your agent’s
agent.tsto register the remote A2A agent as a Strandstool - Updates the agent’s
serve-localtarget to depend on the target agent’sserve-localtarget - Installs required dependencies
Using the Connected A2A Agent
Section titled “Using the Connected A2A Agent”The generator transforms your agent’s agent.ts to wrap the remote A2A agent as a tool:
import { Agent, tool } from '@strands-agents/sdk';import { RemoteAgentClient } from ':my-scope/agent-connection';import { z } from 'zod';
export const getAgent = async (sessionId: string) => { const remoteAgent = await RemoteAgentClient.create(sessionId); const remoteAgentTool = tool({ name: 'askRemoteAgent', description: 'Delegate a question to the remote RemoteAgent A2A agent and return its reply.', inputSchema: z.object({ prompt: z.string() }), callback: async ({ prompt }) => (await remoteAgent.invoke(prompt)).toString(), }); return new Agent({ systemPrompt: '...', tools: [remoteAgentTool], });};The sessionId parameter is plumbed through from the caller, ensuring consistency for Bedrock AgentCore Observability.
Under the hood, RemoteAgentClient.create(sessionId) returns a Strands A2AAgent configured with a SigV4-signing clientFactory when deployed to AWS, and a plain http://localhost:<port>/ endpoint when SERVE_LOCAL=true.
Infrastructure
Section titled “Infrastructure”After running the connection generator, you need to grant the host agent permission to invoke the remote A2A agent.
const remoteAgent = new RemoteAgent(this, 'RemoteAgent');const myAgent = new MyAgent(this, 'MyAgent');
// Grant the host agent permission to invoke the remote A2A agentremoteAgent.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.
module "remote_agent" { source = "../../common/terraform/src/app/agents/remote-agent"}
module "my_agent" { source = "../../common/terraform/src/app/agents/my-agent"}
# Grant the host agent permission to invoke the remote A2A agentresource "aws_iam_policy" "agent_invoke_a2a" { name = "AgentInvokeA2aPolicy" policy = jsonencode({ Version = "2012-10-17" Statement = [{ Effect = "Allow" Action = [ "bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:GetAgentCard", ] Resource = module.remote_agent.agent_core_runtime_arn }] })}
resource "aws_iam_role_policy_attachment" "agent_invoke_a2a" { role = module.my_agent.agent_core_runtime_role_arn policy_arn = aws_iam_policy.agent_invoke_a2a.arn}The remote agent’s AgentCore runtime ARN is automatically registered in the agentcore namespace of Runtime Configuration by the generated Terraform module, so the host agent can discover it at runtime.
Local Development
Section titled “Local Development”The generator configures the host agent’s serve-local target to:
- Start the connected A2A agent(s) automatically
- Set
SERVE_LOCAL=trueso the generated client connects directly tohttp://localhost:<port>/instead of AgentCore
Run the agent locally with:
pnpm nx <agent-name>-serve-local <project-name>yarn nx <agent-name>-serve-local <project-name>npx nx <agent-name>-serve-local <project-name>bunx 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.