DEV Community

Cover image for Build Multi-Agent Systems Using the Agents as Tools Pattern
Laura Salinas for AWS

Posted on

Build Multi-Agent Systems Using the Agents as Tools Pattern

In my last post I covered the Graph pattern and how structured, deterministic workflows can orchestrate multiple agents like a symphony orchestra following a conductor's score.👇🏼

In this final post in this multi agent series, I'm diving into Agents as Tools. I'll share code snippets and examples that you can follow along with to build your own multi-agent system.

The Recap

While Graphs provide structured coordination through dependencies and Swarms enable autonomous collaboration, the Agents as Tools pattern brings hierarchical delegation to multi-agent orchestration. Instead of a single agent trying to handle everything, tasks are delegated to the most appropriate specialized agent.

One thing to note here, when using the Strands framework we are leaving the reasoning, decision making and tool selection to the model used at invocation time. When a query comes in, the agent’s LLM will parse the question and decide on a plan. We can thank Strands’s model-driven loop for this!

What Is an "Agents as Tools" System?

Agents as Tools is an architectural pattern where specialized AI agents are wrapped as callable functions that can be used by other agents. This creates a clear hierarchical structure with two distinct types of agents:

The Orchestrator Agent acts like a manager. It handles user interaction, understands requests, and determines which specialized agent to call. Think of it as the traffic controller for your multi-agent system.

Specialized Tool Agents are the domain experts. Each performs specific tasks when called by the orchestrator, bringing deep expertise in their focused area.

Key characteristics of the Agents as Tools pattern:

  • Separation of concerns - Each agent has one focused responsibility
  • Hierarchical delegation - Clear chain of command (orchestrator routing requests)
  • Modular architecture - Add, remove, or modify specialists independently
  • Optimized performance - Agents have tailored prompts and tools for their domain

The benefits of this pattern lie in its simplicity. Unlike Swarms where agents collaborate dynamically, or Graphs where execution follows dependencies, Agents as Tools uses straightforward function calls. The orchestrator simply decides which specialist to invoke based on the user's request.

How Agents as Tools Work

The pattern relies on three core components working together:

The @tool Decorator transforms your Python function into a tool that other agents can use. This is the key mechanism that wraps specialized agents as callable functions.

Specialized Agents are created within these tool functions. Each has a focused system prompt and relevant tools for its domain. They process specific types of requests when called.

The Orchestrator Agent receives the tool functions in its tools list. It reads the tool docstrings (which is why they're crucial!) to understand when to use each specialist.

Here's the flow:

  1. User sends a request to the orchestrator
  2. Orchestrator analyzes the request against available tool docstrings
  3. Orchestrator selects and calls the appropriate specialized agent
  4. Specialized agent processes the request with its domain expertise
  5. Result flows back through the orchestrator to the user

Creating Specialized Tool Agents

Let's break down how to create specialized agents using the @tool decorator:

from strands import Agent, tool
from strands_tools import retrieve, http_request

# Define a specialized system prompt
RESEARCH_ASSISTANT_PROMPT = """
You are a specialized research assistant. Focus only on providing
factual, well-sourced information in response to research questions.
Always cite your sources when possible.
"""

@tool
def research_assistant(query: str) -> str:
    """
    Process and respond to research-related queries.

    Args:
        query: A research question requiring factual information

    Returns:
        A detailed research answer with citations
    """
    try:
        # Strands Agents SDK makes it easy to create a specialized agent
        research_agent = Agent(
            system_prompt=RESEARCH_ASSISTANT_PROMPT,
            tools=[retrieve, http_request]  # Research-specific tools
        )

        # Call the agent and return its response
        response = research_agent(query)
        return str(response)
    except Exception as e:
        return f"Error in research assistant: {str(e)}"
Enter fullscreen mode Exit fullscreen mode

The key elements to notice:

Clear, descriptive docstrings - The LLM reads these to understand when to invoke your tool. Be detailed about what the agent handles and what parameters it expects.

Focused system prompt - Each specialized agent should have a tightly focused prompt that defines its expertise and boundaries.

Error handling - Always include try-except blocks to gracefully manage any issues that arise during execution.

Creating the Orchestrator

The orchestrator is the brain of your multi-agent system. Here's an example of how to build it:

from strands import Agent
from .specialized_agents import research_assistant, product_recommendation_assistant, trip_planning_assistant

# Define the orchestrator system prompt with clear tool selection guidance
MAIN_SYSTEM_PROMPT = """
You are an assistant that routes queries to specialized agents:
- For research questions and factual information → Use the research_assistant tool
- For product recommendations and shopping advice → Use the product_recommendation_assistant tool
- For travel planning and itineraries → Use the trip_planning_assistant tool
- For simple questions not requiring specialized knowledge → Answer directly

Always select the most appropriate tool based on the user's query.
"""

# Strands Agents SDK allows easy integration of agent tools
orchestrator = Agent(
    system_prompt=MAIN_SYSTEM_PROMPT,
    callback_handler=None,
    tools=[research_assistant, product_recommendation_assistant, trip_planning_assistant]
)
Enter fullscreen mode Exit fullscreen mode

Notice something important: we're passing the specialized agent functions—those we decorated with @tool directly into the orchestrator's tools list. The Strands SDK handles all the complexity of making this work on our behalf.

The orchestrator's system prompt is critical. It should provide clear guidance on when to use each specialist, similar to training instructions for a manager coordinating a team.

When to Use Agents as Tools

Agents as Tools is ideal when you have clearly defined specialist domains and need hierarchical delegation. It performs well when you want a simple, maintainable architecture where adding new capabilities means adding new tool functions.

Use Agents as Tools when:

  • You have distinct domain expertise that can be cleanly separated
  • A hierarchical structure makes sense for your use case
  • You want straightforward routing logic
  • Each task type can be handled by a single specialist
  • You're building a customer service system, virtual assistant, or help desk

Best Practices 💡

From implementing the Agents as Tools pattern, here are some best practices:

  • Write crystal-clear docstrings - The LLM uses these to decide when to invoke your tool, so be descriptive and specific
  • Keep system prompts tightly focused - Each specialized agent should know exactly what it's responsible for and nothing more
  • Include comprehensive error handling - Every tool function should gracefully handle failures and return meaningful error messages
  • Give explicit routing guidance - Your orchestrator prompt should clearly explain when to use each specialist
  • Use consistent response patterns - Make sure all your specialized agents return responses in a similar format

Comparing the Multi-Agent Patterns

Now that we've covered all three patterns in this series, here's when to choose each:

Use Swarm when:

  • The problem benefits from exploration and brainstorming
  • Agents need to dynamically decide who should handle what
  • Collaboration and handoffs are central to the solution
  • The optimal agent sequence isn't known upfront

Use Graph when:

  • You have a clear workflow with known dependencies
  • Deterministic execution order is important
  • You need conditional branching or parallel processing
  • You're modeling a business process

Use Agents as Tools when:

  • You have clearly defined specialist domains
  • A hierarchical structure with a coordinator makes sense
  • You want simple, straightforward routing
  • Each task type maps to a single specialist

Often, you'll combine these patterns! For example, you might use Agents as Tools as your top-level pattern, with some specialists internally using a Graph or Swarm for their complex tasks.

Wrapping Up

This completes our journey through Strands multi-agent patterns! We've covered Swarms for autonomous collaboration, Graphs for structured orchestration, and now Agents as Tools for hierarchical delegation.

Each pattern has its strengths, and knowing when to use which is key to building effective multi-agent systems. Don't be afraid to mix and match patterns to solve your specific use case. As a reminder I have a FREE 2hr video course that you can enroll in to learn all about multi-agent systems at your own pace with step by step code examples.

Don't forget to give me a 🦄 if you got this far and let me know what else you're learning about in these agentic times!

Happy building!

Additional Resources 📚

Top comments (0)