Course Classroom

Tool use in AI agents: Barcelona is listed, but is it available?

Lesson summary

The company offers Barcelona, but the availability check returns an unavailable status. To explain both facts, trace three requests. For each, distinguish what the user needs, the selected function, its input and the returned value.

Lesson 4 / 4 · 5 min · Beginner · English

Start here

In this lesson

  1. Separate membership of a list from current status
  2. Compare the first two requests side by side
  3. Split the non-European request into two conditions
  4. What do Auto and Required change?

Separate membership of a list from current status

A model can generate text. Loyalty points, flight status and a particular booking require information from the application. The lesson uses examples from calculators to CRM lookups. In the travel notebook the distinction is deliberately small: one function supplies destinations; another checks availability for a particular place.

Read what the example actually returns

The upper function lists five cities. The lower one accepts a destination argument, yet the code on screen returns a fixed set of status lines. Do not expect a single Barcelona row simply because Barcelona was the argument. Locate the matching row inside the returned data.

Company catalogue → Availability lookup → Booking confirmation

The catalogue and sample statuses in one notebook 03:05 · Microsoft Learn

Three steps at the screen

  1. Count the five catalogue entries: Barcelona, Paris, Berlin, Tokyo and New York.
  2. Write down only the available ones: Paris, Berlin and New York.
  3. Apply the condition outside Europe. Of Tokyo and New York, only New York meets both tests.

Compare the first two requests side by side

The first asks about destinations. The get_destinations call returns the catalogue. The next names Barcelona. The get_availability function takes that city as input and reports that it is unavailable. A correct catalogue cannot substitute for the second answer. Locate the returned value on screen before reading how the agent expresses it to the user.

Barcelona’s availability response beneath the catalogue. 04:30 · Microsoft Learn

Split the non-European request into two conditions

The traveller wants somewhere outside Europe that is also available. In the recording the model identifies Tokyo and New York as geographical candidates. It checks both with the tool. New York is available and Tokyo is not. Mark each condition independently when reviewing the answer. Being outside Europe cannot establish booking status. These are example values from the notebook.

The run displays status checks for two cities. 05:41 · Microsoft Learn

The Auto function-choice setting 03:24 · Microsoft Learn

Auto allows the model to select a function. Requiring a call does not supply a missing data source or correct a bad argument. Give “tool called” and “requested status verified” separate checkboxes.

What do Auto and Required change?

Auto allows the model to decide whether a function is needed. Required can oblige it to select one. Neither setting guarantees the correct city argument or a successful service response. Limit a tool to the data its task needs. Design different customer messages for a service that cannot be reached and one that actually returns “unavailable.”

A function name cannot validate the answer

At 04:09 the expanded get_destinations entry shows the returned places and the assistant’s text below. Read the next request in the same order: question, function, matching return line, final sentence. A real deployment must also establish source and freshness. This notebook is not consulting a live booking system.

Expanded call for the catalogue question 04:09 · Microsoft Learn

Worked example · Read the run at three stops

Pause

Where to look

How to interpret it

04:00

Catalogue request

get_destinations returns a list. That can answer which places the company offers. A second source is needed to promise a currently available place.

04:30

Barcelona request

get_availability takes a specific city and returns unavailable. Reporting “we do not offer Barcelona” would confuse a status record with a catalogue entry.

05:30

Outside Europe

Tokyo and New York meet the geographical condition and are checked. New York is available. Even if the user sees only one city, the reviewer should be able to trace why the other was excluded.

Try it yourself · Build a three-row call trace

Put the catalogue question in the first row and label the output as a list. Put Barcelona and its status in the second. Split the final row into Tokyo and New York. The evidence you are looking for is a status for each candidate. Combining them into a sentence does not turn two checks into one.

Check your reasoning

Give the trace to someone unfamiliar with the code. Can they distinguish being listed, being available and having a confirmed reservation? If so, the trace communicates what actually happened.

Troubleshooting

Observation

Check

Expected result

Barcelona is listed but cannot be booked

Read membership separately from the status value.

It is offered and currently unavailable in the example.

Tokyo wrongly recommended

Compare its status row to New York’s.

Geography alone is insufficient.

Two review questions

  1. What evidence supports “Did you reserve New York?”
  2. What status follows from a timeout?

Check your reasoning

  1. Only an availability result is present. No booking action or confirmation was shown.
  2. Unknown or unverified. A timeout is not a negative availability value.

Short glossary

Argument: input to a function. Return value: the function’s result. Availability: status in the example data.

Sources and version note

Microsoft distinguishes function choice behaviour from the functions advertised to the model. Requiring a call does not add a missing data source. Microsoft

Microsoft Learn · 4/10 · YouTube