# Mission 12.1: Does the model check the weather itself?

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-12-1

Belongs to [Chapter 12: Integrations](https://llm.yoga/en/12-integrationen.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Laura**, product manager at a customer:

> “In our app, someone asks: ‘Do I need a jacket in Hamburg right now?’ Claude then calls our weather API. So we have to give Anthropic the key for our weather service, right? Our security team won’t like that at all.”

An API is an interface: the way a program talks to a service, such as the weather service or Claude. Laura’s app describes a tool “Check weather” to Claude: what it’s for and which detail it needs, the city. The question is who actually calls it in the end.

**Question 1 (prediction):** Who calls the weather service?

- A) Claude itself, over the internet, as soon as it needs the weather.
- B) Anthropic’s servers, just like with the built-in web search.
- C) Laura’s app; Claude only writes down what should be called.

## What’s behind it

Picture an expert in a room with no phone. The only link to the world is a mail slot. You give her forms, such as “Weather lookup, field: city”. She fills out the right one and pushes it out. Outside, a helper carries it out and hands the result back. Only then does she write her answer.

This is called **tool use**, or function calling. The app describes each tool with a name, a sentence on what it’s for, and the details it needs. If Claude needs one, it responds with a call instead of text: tool “Check weather”, city Hamburg. The response also carries a **stop reason** (stop_reason), here “tool_use”: it’s the app’s turn. The app runs the tool and sends the result back, with the same ID as the call. Because the API remembers nothing between two requests, the whole conversation goes along again. If the tool fails, the app reports that too, as a result with an error flag. Then Claude answers, stop reason “end_turn”: done.

For Laura, this means the key stays with her. Her app sees every call before it happens and can check it, reject it or ask first. The security of agents is built on this; agents are programs in which a model uses several tools one after another on its own. Normally, Claude decides on its own whether to use a tool on offer. Without a tool, a model can only guess the weather: on the test Mac, the MacBook I use for every measurement in this course, a small local model without a tool made up the weather in Hamburg, 5 to 10 degrees in one run and 12 to 18 degrees in another. With the tool, it wrote no text, only the call with the city Hamburg.

### In more detail: what a tool call costs

Tools are in the context as text with every request: according to the docs, Claude Opus 5.5 adds 286 tokens for the built-in tool prompt, plus names, descriptions and schemas. On the test Mac, qwen3:1.7b read the weather question as 166 tokens with the tool and 25 without it.

Every call is another complete request. For the weather question, the chapter works through two rounds with example values: 962 input and 130 output tokens, about $0.0064 with Opus 5.5.

Claude can call several tools in one response. Then all `tool_result` blocks go together in the next message. If a tool fails, it still gets its `tool_result`, with `"is_error": true` and a short explanation.

### How tybo does it: approval via button

tybo, the assistant the course uses as an example, runs the tools itself for its fallback models. According to its architecture docs, every MCP tool there that isn’t registered as read-only waits for approval via a button; without approval, it doesn’t run. That’s exactly the moment between call and execution that Laura’s app has. Where Claude Code runs the tools itself, its own permissions apply instead.

## Try it

**Laura’s weather question, message by message**

**Task:** Play Laura’s app. After each message, decide what the app has to do now, until the answer reaches the user.

1. **Laura’s app asks Claude (request 1)**

   “Do I need a jacket in Hamburg right now?”

   Plus the tool description: “Check weather: returns the current weather for a city in Germany, with temperature, conditions and wind. Input: city, required.”

2. **Claude responds**

   “I’ll check the weather in Hamburg.”

   Plus a call: tool “Check weather”, city “Hamburg”, ID toolu_01A…

3. **Question 2 (decision):** The response ends with the stop reason “tool_use”. What does Laura’s app do now?

   - A) Show the sentence, done.
   - B) Run the tool with “Hamburg”.
   - C) Wait until Claude fetches the weather.

4. **The weather service answers the app**

   Temperature 7 degrees, drizzle, wind 25 km/h.

5. **Question 3 (decision):** The app has the result. What does it send to Claude?

   - A) Just the result.
   - B) Show the result to the user right away.
   - C) Everything again, plus the result.

6. **Laura’s app asks Claude (request 2)**

   Question and response 1 unchanged, plus the result for toolu_01A…: 7 degrees, drizzle, wind 25 km/h.

7. **Claude responds**

   “Yes. It’s 7 degrees in Hamburg right now, with drizzle and wind at 25 km/h. A waterproof jacket is a good idea.”

8. **Question 4 (decision):** The response ends with the stop reason “end_turn”. What now?

   - A) Show the answer, done.
   - B) Run the tool again.

Messages follow the pattern from Anthropic’s docs. They are shortened and paraphrased, not shown in the raw API format; the ID is cut off, and the tool is made up. (Checked against the documentation, not run here)

## Check

**Question 5 (check question):** Why is it good that the model doesn’t run tools itself?

- A) Because that way the answer reaches the user faster.
- B) Because the app sees every call beforehand and can check it.
- C) Because then tools don’t cost any tokens.

**Question 6 (check question):** Laura’s weather service is down. What does the app send to Claude?

- A) Nothing at all; it shows the user an error message.
- B) The user’s next question, as if nothing had happened.
- C) A result with an error flag and a short explanation.

**Question 7 (check question):** In Laura’s app, the user asks: “How many days are in a week?” The weather tool is included, as always. What happens?

- A) Claude answers directly, without a tool call.
- B) Claude checks the weather anyway, because the tool is on offer.
- C) The app has to remove the tool first, otherwise there’s an error.

## Done

**What you can do now**

- You can explain that a model only writes down a tool call, and the app runs it.
- You can follow a tool call message by message: call, result with the same ID, answer.
- If a customer asks whether they have to give Anthropic their access keys so Claude can use their services, you explain that their app runs every call itself and can check it beforehand.

### Two cards for review

**Card 1:** True or false? “If an app offers Claude a tool, Claude calls the service behind it directly.”

**Card 2:** True or false? “If the service behind a tool goes down, the app should send nothing back to Claude.”

- [Next mission: We need guaranteed JSON](https://llm.yoga/en/einsatz-12-2.md)
- [Try it on your Mac](https://llm.yoga/en/mac-12-1.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [Tool use](https://llm.yoga/en/12-integrationen-1.md)
- [Walkthrough: a weather question with one tool](https://llm.yoga/en/12-integrationen-2.md)
- [API basics: a letter over HTTP](https://llm.yoga/en/12-integrationen-1.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is C.
- A: A language model has no network access. It only produces text, piece by piece. Whatever it “does”, it writes down as text, and a program carries it out.
- B: Web search is a tool that Anthropic runs itself. A tool that Laura describes herself, on the other hand, runs in her app.
- C, correct: The key for the weather service stays in the app; Anthropic never sees it. Claude delivers a call in a fixed form, and the app carries it out and sends the result back.

**Question 2:** The correct answer is B.
- A: Then the user would only get “I’ll check the weather in Hamburg.” and never the weather. “tool_use” means: it’s the app’s turn.
- B, correct: That is, call its own weather service with its own key. Here the app can also check whether the input is plausible and whether the tool may run without asking first.
- C: Claude doesn’t fetch anything. Without the app, nothing happens from here on.

**Question 3:** The correct answer is C.
- A: Claude still knows what this was about, doesn’t it? No: the API remembers nothing between two requests. Without the question and the call, Claude wouldn’t know what the numbers belong to.
- B: Then she would get raw data instead of an answer to her question. Whether 7 degrees and drizzle mean “yes, jacket” is what Claude puts into words.
- C, correct: The question, Claude’s response unchanged, the result with the same ID as the call, and the tool description again. The ID toolu_01A… connects result and call.

**Question 4:** The correct answer is A.
- A, correct: “end_turn” means: no further tool needed. At its core, an agent is exactly this loop: as long as Claude sends a call, the program carries it out and asks again.
- B: There’s no new call, so there’s nothing to run. Every extra round would be another complete request and cost tokens.

**Question 5:** The correct answer is B.
- A: It doesn’t get faster; every call costs another request. The advantage lies elsewhere.
- B, correct: It can reject it or have it approved. That’s the starting point for every safeguard in agents: a program decides, not the model. More on this in chapter 18.
- C: The tool descriptions go along as text with every request and cost tokens, even if no tool is used.

**Question 6:** The correct answer is C.
- A: Then the call stays unanswered. The API expects a matching result for every call; otherwise the history is invalid.
- B: Without a result for the call, the request fails. And even if it didn’t, Claude wouldn’t know that its call failed.
- C, correct: That way Claude knows what went wrong. It can try something else or honestly tell the user that the lookup isn’t working right now.

**Question 7:** The correct answer is A.
- A, correct: Normally the model decides on its own whether it needs a tool. On the test Mac, asked in German, even the small local model with the tool answered directly: „Eine Woche hat 7 Tage.“ (German for “A week has 7 days.”)
- B: On offer doesn’t mean forced. With the new Claude models, you can’t force a tool anymore anyway.
- C: No error. An unused tool only costs the tokens for its description.

**Card 1:** **False.** Claude only writes down a call: which tool, with which inputs. The app carries it out, with its own keys, and sends the result back. That’s why it can check, reject or require approval for every call beforehand. Only tools that Anthropic runs itself, such as web search, run on Anthropic’s side.

**Card 2:** **False.** Every call needs a result with the same ID; otherwise the history is invalid. The app reports the outage as a result with an error flag and a short explanation. Then Claude can try something else or honestly tell the user that it isn’t working right now.
