Skip to content

TypeScript Agent to A2A Agent

The connection generator can connect your TypeScript 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 TypeScript project with a Strands Agent component (any protocol)
  2. A project with an Agent component generated with --protocol=A2A and --auth=IAM (either ts#agent or py#agent)
  3. Both components created with infra: agentcore
  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.
    preferInstallDependencies boolean true Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.

    The generator creates a shared agent-connection package and modifies your agent code:

    • Directorypackages/common/agent-connection
      • Directorysrc
        • Directoryapp
          • <target-agent-name>-client-strands.ts High-level Strands client for the connected A2A agent
        • Directorycore
          • agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
          • agentcore-fetch.ts Framework-agnostic SigV4 / JWT / session-forwarding fetch
          • agentcore-a2a-client-config.ts Framework-agnostic A2A client config (signed clientFactory)
          • agentcore-a2a-client-strands.ts Strands A2A client wrapping the config
        • index.ts Exports all clients
      • project.json
      • tsconfig.json

    Additionally, it:

    • Transforms your agent’s agent.ts to register the remote A2A agent as a Strands tool
    • Updates the agent’s dev target to depend on the target agent’s dev target
    • Installs required dependencies

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

    packages/example/src/my-agent/agent.ts
    import { Agent, tool } from '@strands-agents/sdk';
    import { RemoteAgentClientStrands } from ':my-scope/agent-connection';
    import { z } from 'zod';
    export const getAgent = async (sessionId: string) => {
    const remoteAgent = await RemoteAgentClientStrands.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, RemoteAgentClientStrands.create(sessionId) returns a Strands A2AAgent configured with a SigV4-signing clientFactory when deployed to AWS, and a plain http://localhost:<port>/ endpoint when LOCAL_DEV=true. The signing and endpoint resolution live in the framework-agnostic agentcore-a2a-client-config.ts; only the thin agentcore-a2a-client-strands.ts depends on Strands.

    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 dev target to:

    1. Start the connected A2A agent(s) automatically
    2. Set LOCAL_DEV=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>-dev <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.