Skip to content

Conversation

@pkdey-aws
Copy link
Contributor

@pkdey-aws pkdey-aws commented Dec 8, 2025

Closes Issue #232

Problem

The initial A2A (Agent-to-Agent) discovery pattern attempted to dynamically load discovered agents as native Strands tools. However, we encountered a fundamental limitation: Strands Agent tool lists are immutable after initialization.

When an Agent is created, the tools list becomes frozen as part of the LangGraph execution infrastructure. This means we cannot dynamically add newly discovered agents as tools at runtime, which breaks the original design where each discovered agent would become a callable tool.

Solution

We refactored the agent discovery pattern to use a local cache with predefined proxy tools instead of dynamic tool creation:

New Architecture

  1. Local Agent Cache (RemoteAgentCache)

    • Maintains a dictionary of discovered remote agents
    • Stores RemoteAgentClient instances with lazy initialization
    • Persists across tool calls without requiring network requests
  2. Three Predefined Proxy Tools (CRUD-style interface)

    • discover_remote_agents(query, max_results) - Discover agents via semantic search and cache them locally
    • view_cached_remote_agents() - Read all cached agents and their metadata
    • invoke_remote_agent(agent_id, message) - Invoke a specific cached agent by ID
  3. Benefits

    • Works within Strands' immutable tool constraint. Enables agent discovery without modifying the the original agent's tool list
    • Provides clear, predictable tool interface for the LLM
    • Maintains A2A protocol compatibility

Testing

The testing approach validates the complete agent discovery workflow in a local Docker environment:
python3 agent_discovery_test.py --endpoint local

  1. Environment Setup

    • Launch the entire registry service locally via Docker Compose
    • Deploy all agents (travel-assistant, flight-booking, etc.) on the same Docker network
    • Ensure all services can communicate through the shared network
  2. Test Scenarios

    • Baseline Test: Send a prompt to the travel agent that can be solved using only its built-in tools (flight search, trip planning, etc.)
    • Discovery Test: Sends a prompt that requires capabilities the travel agent doesn't have, forcing it to:
      1. Use discover_remote_agents() to search the registry semantically
      2. Use view_cached_remote_agents() to inspect discovered agents
      3. Use invoke_remote_agent() to call the discovered agent and complete the task

Known Issues

Docker Network Communication

  • Error Type: 404path resolution errors through nginx reverse proxy. Travel Agent -> Registry

Current Status:

  • Updated nginx configuration files to properly route A2A agent traffic
  • Changes should resolve the path resolution issues
  • Requires additional testing on other machines to confirm the fix

@pkdey-aws pkdey-aws changed the title Temp Strands A2A Discovery and Invocation Pattern Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant