Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Tool Selection
The agent controller selects which tool to use based on the tool descriptions and the current goal. Clear descriptions are the key to accurate tool selection.
How the Agent Selects a Tool
The agent controller (the language model) selects a tool by reading:
- 1The current goal
- 2The current state (what has been done so far)
- 3The available tool descriptions
It then reasons: 'Given what I need to do next, which tool best matches?'
This is why descriptions are so important. If two tools have similar descriptions, the agent may pick the wrong one. If a description is too vague, the agent may skip a useful tool entirely.
Example decision reasoning:
Goal: Find the current price of product #A12
Available tools: web_search, get_product_price, send_email
Agent reasoning: I need a specific product price. 'get_product_price' is a direct match. 'web_search' would also work but is less precise. I will call 'get_product_price'.
Tool Selection Rules
- Use the most specific tool available — prefer 'get_product_price' over 'web_search' for prices
- Do not use write tools when a read tool is sufficient
- If no tool matches, stop and escalate rather than using an inappropriate tool
- If multiple tools could work, prefer the one with fewer side effects
- Validate that the required arguments are available before calling a tool
Key Takeaways
- The agent controller selects which tool to use based on the tool descriptions and the current goal.
- Use the most specific tool available — prefer 'get_product_price' over 'web_search' for prices
- Do not use write tools when a read tool is sufficient
- If no tool matches, stop and escalate rather than using an inappropriate tool