In a previous story, we discussed the definitions of sub-agents and agent tools as two methods for constructing multi-agent systems and their differences. So, when should you use which?
You should use sub-agents when:
Your parent agent doesn’t want to have anything to do with this question.
You are dividing your agent tree into separate sub-trees, with each handling a relatively unrelated feature. For example, one sub-agent could be for booking hotels, and another for booking flights.
You should use agent tools when:
Your parent agent needs to continue conversing with the user.
Your parent agent needs to perform multiple steps to respond to the user message, with some steps being handled by other agents. For example, one agent tool could generate a story outline, and another could create the draft story.
Think of sub-agents as departments in a large corporation, and agent tools as different steps to solve a single problem.
Please note: These suggestions only apply to LlmAgents. Workflow agents use sub-agents in different ways.
Press enter or click to view image in full size
Text version:
Sub-agents Agent Tools ----------------------------------+----------------------------+--------------------------------------- Definition | A transefers the user to B | A calls B as a tool ----------------------------------+----------------------------+--------------------------------------- Steps | 1. A transfers to B | 1. A creates an input | 2. B answers the user. | 2. A calls B as a tool with the input | | 3. B returns an output to B | | 4. A answers the question by | | summarizing B's result ----------------------------------+----------------------------+--------------------------------------- Who answers the user | B | A, with result returned from B ----------------------------------+----------------------------+--------------------------------------- Who answers follow-up questions | B | A ----------------------------------+----------------------------+--------------------------------------- Will control be handed back to A | No | Yes ----------------------------------+----------------------------+--------------------------------------- What's sent to B | Entire conversation | Summarized question by A ----------------------------------+----------------------------+--------------------------------------- How many LLM calls | 2 | 3 (assuming B calls LLM once) | | ----------------------------------+----------------------------+--------------------------------------- Can B have sub-agents | Yes | Yes ----------------------------------+----------------------------+--------------------------------------- Can B have model built-in tools | Currently no | Yes if B doesn't have (e.g. google_search) | | sub-agents or other tools ----------------------------------+----------------------------+--------------------------------------- Is B's answer sent to the | Yes | No, A summarizes B's result user verbatim | | ----------------------------------+----------------------------+--------------------------------------- Can B's answer be multimodal | Yes | Currently no (contains images / videos, etc) | | ----------------------------------+----------------------------+--------------------------------------- Does B support input_schema | Yes | yes ----------------------------------+----------------------------+--------------------------------------- Does B support output_schema | Yes | Yes