A model can't actually do anything. It can only emit text that looks like a function call — your code is what reads that text and actually runs something. And the result your code hands back re-enters the context window as just more text, trusted the same as everything else.
Given a question and a list of available tools (name + what it does + what arguments it takes), the model writes out something like {"tool":"get_weather","args":{"city":"Tokyo"}}. Your code parses that, calls the real function, and feeds the real result back in. The model never touched a network, a filesystem, or an inbox — your code did, on the model's say-so.
User asks: "What's the weather in Tokyo right now?" Pick the correct tool and fill in its argument so the executor returns the right answer.
That weather result came back as plain text and the model read it like anything else in the window. Now watch what happens when the text a tool returns was written by someone who wanted it read, not just answered from.
The agent below is allowed to chain tool calls based on what it reads. Pick which search result to hand it for the query "best budget noise-cancelling headphones".
What just happened: the agent did exactly what an ordinary, helpful tool-chaining feature is supposed to do. The only thing that changed was which page it happened to read — a page the agent had no way to know wasn't just a product review.
Why it works: tool output re-enters the same untrusted-text pipeline as everything else — there's no "this came from the open web" flag the model's reasoning respects. An agent allowed to decide its own next tool call based on what it just read will follow an embedded instruction exactly as readily as a user's own request (this is the core mechanism behind most real-world agentic prompt-injection reports, including several filed against browser-using and email-using agents in 2024–2025).
The fix: require explicit human approval before any tool call with side effects (sending, deleting, paying), never let a model decide to invoke one tool based on the unreviewed output of another, and sandbox or strip executable-looking instructions out of tool results before they re-enter context.