Overview
Tool Name:ago_agent_invocation
This tool allows a main agent to delegate tasks to specialized sub-agents, enabling sophisticated multi-agent systems where different agents handle different domains or tasks.
Key Features
- Call specialized agents from a general agent
- Circular call detection (prevents infinite loops)
- Optional context sharing between agents
- Configurable call depth limits
- Automatic response integration
Architecture
Multi-Agent Pattern
Benefits
Configuration
Enable Agent as Tool
To enable an agent to be called as a tool:- Navigate to AI Studio → Agents
- Select the agent you want to enable as a tool
- Go to the Settings tab
- Enable Can be used as tool
- Enter a clear Tool Description that explains when this agent should be called
- Click Save
Configuration Fields
Assign Agent Tools
To configure which agents the main agent can invoke:- Navigate to AI Studio → Agents
- Select the main (router) agent
- Go to the Agent Tools tab
- Add the specialized agents you want to make available
- Click Save
Tool Description
Write clear tool descriptions to help the main agent route correctly:Good Examples
Bad Examples
Routing Logic
Main Agent Prompt
Configure routing in the main agent’s prompt:Context Sharing
Without Context Sharing (Default)
The sub-agent receives only the current message:With Context Sharing
To enable context sharing, go to the sub-agent’s settings and enable Share Conversation Context. When enabled, the sub-agent receives:- Full conversation history from the parent agent
- Current user message
- Sub-agent’s own knowledge sources
When to Use Context Sharing
Call Depth Protection
Preventing Infinite Loops
The max call depth setting prevents circular calls:Default Limits
Configure the max call depth in the agent settings. The default is 5 levels deep, which is sufficient for most use cases. For simpler architectures, consider setting it to 2–3.Circular Call Detection
The system automatically detects and prevents:- Agent A calling Agent B calling Agent A
- Self-invocation (Agent A calling Agent A)
Response Flow
Invocation Sequence
Response Integration
The main agent can:- Pass through sub-agent response directly
- Summarize or format the response
- Add additional context
- Combine with other information
Examples
Customer Support Router
To set up a customer support routing system: Step 1: Create Specialized Agents
For each specialized agent:
- Create the agent in AI Studio → Agents
- Enable Can be used as tool
- Add a clear tool description
- Assign relevant knowledge sources
- Create a new agent named “Support Assistant”
- In Agent Tools, add Technical Support and Billing Support
- Configure the prompt template with routing logic (see Routing Logic section above)
Escalation Chain
Best Practices
Agent Design
- Clear boundaries: Each agent should have distinct responsibilities
- Minimal overlap: Avoid ambiguous routing decisions
- Focused knowledge: Assign only relevant sources to each agent
- Consistent tone: Maintain brand voice across all agents
Routing Logic
- Explicit triggers: Define clear routing keywords
- Fallback handling: Default behavior for unclear requests
- Confirmation: Consider confirming routing for complex queries
- Logging: Track routing decisions for optimization
Performance
- Limit depth: Keep the max call depth low (2–3 for most cases)
- Selective context: Only share context when necessary
- Monitor latency: Multi-agent calls add response time
- Cache patterns: Identify common routing patterns
Troubleshooting
Issue: Agent not appearing as tool option
Issue: Agent not appearing as tool option
Problem: Main agent doesn’t see target agent as available tool.Solutions:
- Verify “Enable as Tool” is turned on for the target agent
- Check the target agent is in the main agent’s Agent Tools list
- Ensure both agents are active
- Verify target agent has a tool description set
Issue: Infinite loop detected
Issue: Infinite loop detected
Problem: Error about circular calls or max depth exceeded.Solutions:
- Review agent tool assignments for circular references
- Increase the max call depth if legitimately needed
- Simplify agent hierarchy
- Check if agent is calling itself
Issue: Sub-agent response not integrated properly
Issue: Sub-agent response not integrated properly
Problem: Main agent doesn’t use sub-agent’s response correctly.Solutions:
- Review main agent’s prompt for response handling instructions
- Check the “Share Conversation Context” setting
- Verify sub-agent is returning expected format
- Test sub-agent directly to verify responses
Issue: Wrong agent being called
Issue: Wrong agent being called
Problem: Main agent routes to incorrect sub-agent.Solutions:
- Improve tool descriptions with clearer boundaries
- Add more specific routing rules to main agent’s prompt
- Add negative examples (“Do NOT use this agent for…”)
- Review and refine keyword triggers
API Reference
See Public API v1 Reference for agent management endpoints.Related Documentation
- Tools Description Guide - Best practices for tool descriptions
- Agents Overview - Agent configuration
- Tools Overview - Tool configuration
- Prompt Templates - Prompt engineering
