An AI agent is asked to prepare a customer for a delayed flight. It can search bookings, check live flight status, read the airline policy, calculate refund eligibility, and send a message.
Several tools look relevant. None of them, by itself, completes the job. The agent has to choose a useful first move, supply valid arguments, inspect what comes back, and decide what the new evidence makes possible.
That is the practical shape of tool selection. It is not usually a hard-coded rule that says, “When the user mentions a delay, call tool number three.” The application presents capabilities to a model, the model produces a tool call when one appears useful, and the surrounding software executes it and returns an observation. Then the loop can continue.
What the model can see
A tool-enabled model does not inspect the implementation behind every API. It generally sees a model-facing definition: a name, a description, and an input schema. The application may also provide instructions about when a tool may be used, which tools are currently available, and whether approval is required.
For the flight task, the available tools might look roughly like this:
find_booking
Find a reservation by confirmation code and passenger surname.
inputs: confirmation_code, surname
get_flight_status
Get the latest operational status for one flight on one date.
inputs: flight_number, departure_date
search_policy
Search current airline policy documents for a specific question.
inputs: query, jurisdiction
calculate_refund_options
Calculate options for a verified booking and disruption.
inputs: booking_id, disruption_code
send_customer_message
Send an approved message to a customer.
inputs: customer_id, subject, body
The names provide quick semantic cues. Descriptions explain purpose and boundaries. Schemas constrain the arguments: which fields exist, their types, which are required, and sometimes which values are allowed. Clear definitions make a better decision more likely, which is the builder-facing problem covered in Designing Tools a Model Can Actually Use.
But definitions are only part of the input. The model also has the current request, system and application instructions, relevant conversation or task state, and prior tool results still available in context. If the customer already supplied a confirmation code, that changes the viable first call. If a prior lookup returned a booking ID, a downstream tool may now be usable. If the context is crowded with stale or duplicated material, selection can become less reliable, as discussed in Why More Context Can Make an AI Agent Worse.
A realistic selection sequence
Suppose the customer says:
My flight tomorrow was delayed and I need to know my options. My confirmation is K7M2QX, under Walton. Please draft a message I can send to my team, but do not contact anyone yet.
1. Narrow the candidates
The request mentions a flight, a reservation, policy-dependent options, and a message. Four tools are plausible. The instruction not to contact anyone removes send_customer_message from the immediate path. calculate_refund_options is also premature because its schema requires a booking ID and disruption code that the agent does not have.
find_booking has both required inputs in the request, so it is a strong first candidate. The model can produce something like:
{
"confirmation_code": "K7M2QX",
"surname": "Walton"
}
This is argument construction, not mere routing. The model maps language from the request into the tool’s fields. A strict schema can reject malformed arguments, but it cannot guarantee that the model extracted the right surname or chose the right tool.
2. Inspect the observation
The booking tool returns a booking ID, customer ID, flight number, departure date, and itinerary. That result is added to the working context. It is evidence for the next decision, not proof that the whole task is finished.
Now get_flight_status can be called with the exact flight number and date. Imagine it returns:
{
"flight_number": "RW418",
"status": "delayed",
"delay_minutes": 195,
"disruption_code": "CREW",
"last_updated": "2026-09-02T08:42:00-04:00"
}
The timestamp and disruption code matter. A result that merely says “delayed” may be too thin for the next step. Good tool output helps the model determine whether it has enough evidence to continue, needs a more precise query, or should stop and explain uncertainty.
3. Use new evidence to choose the follow-up
The agent can now search the current policy with a specific question tied to the delay and jurisdiction. It can also call calculate_refund_options because the required booking ID and disruption code are now known.
Some platforms can return more than one tool call in a model response, and independent lookups may sometimes run in parallel. That is an implementation capability, not a universal property of agents. These two calls may also be kept sequential when one result could change whether the other is appropriate, when rate limits matter, or when the host only supports one call at a time.
Once the policy excerpt and calculated options return, the agent compares the observations with the request. It can summarize the choices and draft the team message in ordinary text. It should not call the sending tool because the user explicitly prohibited that action. Choosing no further tool is still a tool-selection decision.
What happens when the first call fails
Tool use becomes more revealing when something goes wrong.
Suppose find_booking returns NOT_FOUND and says the confirmation code must be six alphanumeric characters. Retrying the exact same call is unlikely to help. The agent should inspect the failure signal and choose among a few bounded responses:
- correct an obvious formatting error if the source value is unambiguous;
- ask the user for the missing or questionable value;
- try a documented alternate lookup tool if one exists and its requirements are met;
- stop rather than inventing a reservation or claiming success.
A timeout is different from a validation error. Before retrying a tool that changes state, the system may need an idempotency key or a read-back check to determine whether the first attempt actually succeeded. Recovery depends on the semantics of the action and the evidence returned, not just the fact that an error occurred.
This is why a useful trace matters. A final answer alone cannot show which candidates were available, what arguments were sent, what came back, or why the agent changed course. Your Agent Needs a Flight Recorder explains what to retain for diagnosis without treating every private detail as permanent telemetry.
The decision flow, without pretending it is a hidden checklist
Task + current context
↓
Available tool definitions — names, descriptions, schemas, and host constraints
↓
Candidate fit — which capability could advance the task, and are its required inputs known?
↓
Choose an action — answer without a tool, ask for information, call one tool, or request multiple calls where supported
↓
Execute outside the model — validate arguments, apply permissions or approvals, run the capability
↓
Return an observation — data, confirmation, warning, validation failure, timeout, or partial result
↓
Reassess — continue, refine, retry safely, recover another way, ask the user, or stop
This diagram is an explanatory model of the loop. It is not a claim that every model follows a literal private checklist, exposes a stable confidence score, or weighs tools in the same way. Implementations vary. Providers and agent frameworks can force a particular tool, require some tool use, restrict the allowed set, insert deterministic validation, or leave the model free to call none, one, or several.
Tool choice is shared between the model and the harness
It is tempting to say “the agent decided,” but the decision is distributed across the system.
- The builder decides which capabilities exist and how they are described.
- The host or harness decides which tools are exposed now, what context is supplied, and what permissions, approvals, timeouts, or call limits apply.
- The model interprets the request and available definitions, then emits text or a structured call.
- The application validates and executes that call, then returns the result.
- The next model turn uses the new observation to decide what follows.
MCP can standardize how an AI application discovers and calls external tools, but it does not dictate how the model should reason about which one to use. Likewise, a sandbox contains where an agent can act; it does not make the selected action correct or authorized.
Production systems often add deterministic controls around the probabilistic choice: schema validation, allowlists, approval gates, argument normalization, duplicate-call protection, budgets, and postcondition checks. Those controls do not remove model judgment. They bound what can happen when that judgment is wrong.
Why the wrong tool still gets chosen
Even strong models can confuse overlapping tools, overvalue a familiar name, miss a condition buried in a long description, or construct an argument from stale context. A tool may be technically relevant but unsafe at that moment. A successful call may return incomplete data. A plausible result may be mistaken for confirmation.
The goal is not perfect selection. It is a system where good choices are legible and bad choices are limited, detectable, and recoverable.
When an agent chooses well, the pattern is usually simple: the available interface matches the task, the needed arguments are grounded in current evidence, the result says enough to guide the next step, and the surrounding software enforces the boundaries the model should not carry alone.