How does an AI Agent decide which tool to call?

The model reads the tool menu and picks the best-matching dish.

Picture it first

Imagine a handyman robot with a toolbox. Each tool has a label: 'Hammer — for nails', 'Screwdriver — for screws', 'Tape — for measuring length'. You say 'Hang this picture'. The robot reads the labels and picks the hammer. If two tools had the same confusing label, 'For fixing stuff', the robot would just guess.

Now the same idea, in simple QA words

An AI agent is an AI that can do things, not just talk — check weather, search flights, create a Jira ticket. It does this using tools. The developer gives the AI a 'menu' of tools, each with a name and a short description of what it does. The AI reads your request, reads the menu, and picks the tool whose description matches best. For QA: if two descriptions are vague or similar, the AI picks the wrong tool.

How the story connects to the real thing

In the storyIn the AI system
Handyman robotAI agent
Toolbox with labelled toolsList of tools with descriptions
'Hang this picture'User's request
Robot reads labels and picks the hammerAI matches request to the right tool

Real-world example

A travel agent bot has tools: search_flights, book_flight, get_weather, convert_currency. The user says 'Is it raining in Goa this weekend? If not, find me a flight from Pune on Saturday.' The model first calls get_weather(city='Goa', date='Saturday'), reads the result, then decides to call search_flights(from='PNQ', to='GOI', date='2026-11-14').

Step by step, in plain words

  1. The app gives the AI a list of tools and what each does.
  2. The user makes a request.
  3. The AI decides: do I need a tool?
  4. If yes, it picks the best-matching tool and fills in the details.
  5. If no, it simply answers.

How a tester tests it

  • Build a tool-selection matrix: for each user intent, the expected tool (or 'no tool').
  • Test ambiguous requests and overlapping tools — does it ask a clarifying question or guess?
  • Test 'no tool needed' prompts — agents often over-call tools.
  • Re-run selection tests whenever a tool description is edited — descriptions are effectively prompts.

Try it yourself

1) Write 4 tool descriptions for a banking bot (balance, transfer, block_card, branch_locator). 2) Write 10 user messages and predict which tool each should trigger; note any message where two tools could fit.

Interview angle

“How do you test that an agent picks the right tool?”

I create a labelled dataset of user intents mapped to the expected tool and arguments, including no-tool and ambiguous cases, and measure tool-selection accuracy. I treat tool descriptions as part of the prompt, so any description change triggers the selection regression suite.