Lecture 5 · COMS W4995 Agentic Engineering

Agent tools in pictures

Chapter two

What a tool is

Take any tool apart into the parts the model sees, the parts that run, and the parts nobody wrote down, then ask it four questions before you trust it.

After this chapter you can

  1. Say in one sentence what a tool is, where it runs, and where the authority to run it sits.
  2. Name a tool’s three layers (contract, implementation, knowledge) and place a given failure in one of them.
  3. Tell a missing capability from missing knowledge, and say what a tool and a skill each supply.
  4. Classify a call as perception, action or computation, and say whether it changes the world.
  5. Ask the four questions of any tool (read or write, what if it runs twice, whose keys, who wrote the contract and the result) and answer them for a real case.

22 minutes to read11 sections10 quiz questions

Start reading →

You type “refund order 4417” into a support agent. A moment later, the model gives you one short line: a name, refund, and an argument, order_id: "4417". Nothing has happened yet. No money moves until a program reads that line, decides to run it, and then runs it. This chapter covers that program, that line, and the gap between them.

Section 2.1

Where the agent ends and the world begins

The agent and its environment. Observations flow from the environment through the harness into the model as text; the model writes a tool call as text; the harness, outlined in orange, turns it into an action in the environment.ENVIRONMENTHARNESSMODELEnvironmentrepository,website, app,workflowHarnessparses, validates,executes the call,returns the resultModelreads tokens,writes tokensobserveresultcallactwhat the agent perceives and changeswhere the actuators really arenever touches the world
The classic agent picture with one change: the actuators of an LLM agent are tool calls, and a harness outside the model carries them out.

We start with the textbook definition: “An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators”2. A robot vacuum fits this definition. Its sensors are a camera and bump switches. Its actuators are wheels and brushes.

Now try the definition on a language model. What are its actuators? A language model has no wheels. It reads tokens and writes tokens. The CMU agents course helps us frame this for LLM agents: the environment is “a repository, website, application, or workflow”, observations include “tool results”, and actions are “replies, file edits, shell commands, API calls, and mouse or keyboard events”1.

How does a model that only writes text produce a shell command? The same course answers this in one line: “A tool call is another token sequence the model can predict”1. Something else must turn that sequence into an effect. On the same slide, the harness “Parses, validates, and executes the call” and returns the result as observation tokens1.

So the actuator of an LLM agent is not inside the model. It is the harness: the program around the model that translates its calls into effects and feeds the results back. CMU describes engineering it as changing “the system around the model: prompts, tools, memory, and control flow” and providing “context, validation, retries, and safety boundaries”1. Anthropic calls its Agent SDK “a powerful, general-purpose agent harness”3.

Why does this distinction matter? Because only one side of it can be made strict. Anthropic’s Claude Code guide puts the two kinds of control next to each other: “Unlike CLAUDE.md instructions which are advisory, hooks are deterministic and guarantee the action happens”4. Instructions go into the model as text, and the model may or may not follow them. Hooks run in the harness, every time. Everything else in this chapter sits on this line.

Check yourselfWhere, physically, does a tool call get executed?

It runs outside the model: in your application, on the provider’s servers, or inside another agent used as a tool. The model only writes the call; a harness “Parses, validates, and executes the call”1. The section “Who runs the tool” below shows the three places.

Section 2.2

One call, one loop

Seven steps of one tool call across two lanes. The model lane holds step 2, write the call, and step 7, read the result and decide what is next. The harness lane holds steps 1, 3, 4, 5 and 6: list the tools, parse and check, allow or ask or deny, run, and return the result with the call ID.MODELHARNESS1listtools2writethe call3parse,check4allow, askor deny5runit6returnwith call ID7read,decide next
Seven steps of one tool call. Only steps 2 and 7 happen inside the model; everything in the box is the harness.

Walk one call from start to finish. Both CMU and Stanford use the same small task: “What does test.py contain?”, answered with a read_file tool1,7.

  1. Before the model writes anything, the harness puts the tool list into the context. “The harness sends messages and tool schemas; the template exposes both to the model”8.
  2. The model writes a call: a tool name and its arguments. “The model emits the call content; the API response attaches a unique call ID”8.
  3. The harness parses the call and checks it against the schema. Stanford’s anatomy of a call has four steps, select, arguments, validate, execute; the first two are the model’s step 2, and validate is this one7.
  4. The harness decides whether to run the call. “The model proposes; external software decides whether and how to execute”8.
  5. The harness runs it. This might be a function, a process, or a request to a remote service.
  6. The result comes back as a message tied to that call. In OpenAI’s Chat Completions API, it is a message with role tool and a tool_call_id, the “Tool call that this message is responding to”5. In Anthropic’s API, your code sends the result back in a tool_result block6.
  7. The model reads the result and then writes the next call or the final answer.

Then the loop starts again. ReAct, a 2022 paper, interleaves reasoning with actions that “interface with and gather additional information from external sources such as knowledge bases or environments”9. The loop itself does not require much code. CMU’s example, mini-swe-agent, describes itself as “Just some 100 lines of python for the agent class”, and it runs every action through a shell with subprocess.run10. Its README claims a score above 74% on SWE-bench Verified without naming the model, so we should treat that number as a headline, not a confirmed result10.

Now look at what the model saw in all of this. It saw the tool list in step 1 and the result in step 6. It did not see the code that ran, the key that code used, or whether a person approved the call. Hugging Face’s agents course states this plainly: LLMs “can only receive text inputs and generate text outputs”, and “They have no way to call tools on their own”11.

Check yourselfWhat exactly does the model see after it calls a tool?

It sees a new message carrying the result, labeled with the call’s ID5,6. It does not see the code, the credential, or the permission decision, unless the harness explicitly writes them into that message.

Section 2.3

Four definitions, one core

Four definitions of a tool in four cards: CMU, Anthropic, Hugging Face and Google. A dark bar underneath states the clause they share: the program runs outside the model, and the model only writes the call.CMUan interface through which a modelinvokes an external program;the model proposes, software decidesANTHROPICa contract between deterministicsystems and non-deterministicagentsHUGGING FACEa function given to the LLM;how it is implementeddoes not matter to the modelGOOGLEa function or program the app usesfor tasks outside the model;the definition declares a contractShared: the program runs outside the model. The model only writes the call.
Four definitions of a tool. The shared clause is the same in all of them; the emphasis changes with whose side the author stands on.

Ask four groups what a tool is and you get four sentences.

Carnegie Mellon University (CMU) uses a 2024 survey by its own researchers as the reading for its tool lecture12. The survey defines a tool as: “An LM-used tool is a function interface to a computer program that runs externally to the LM, where the LM generates the function calls and input arguments in order to use the tool”12. A lecture slide condenses this to: “A tool is an interface through which a language model can invoke an external computer program”, and then adds: “The model proposes; external software decides whether and how to execute”8.

Anthropic emphasizes what is new about the caller: “Tools are a new kind of software which reflects a contract between deterministic systems and non-deterministic agents”13. Their example is the umbrella question: if asked whether to bring an umbrella, an agent might call a weather tool, answer from general knowledge, or first ask for your location13.

Hugging Face begins its definition from the model’s perspective: “A Tool is a function given to the LLM”11. It also states what the model does not need: “the way the tool is implemented does not matter”11.

Google starts from the application’s perspective: a tool is “a function or a program an LLM-based application can use to accomplish a task outside the model’s capabilities”14. It also uses the word contract: “The tool definition declares a contract between the model and the tool”14.

All four definitions agree on the core idea. A tool is a program external to the model, and the model only writes the call to it. They differ in their perspective. Hugging Face writes from the model’s side, focusing on what the model needs to know to select the correct call. CMU writes from the program’s side, focusing on who makes decisions. This course adopts CMU’s perspective: the authority to execute a call rests with the program. This choice is practical. The failures we study in this book—a call that runs twice, a key that accesses too much, a result that contains someone else’s instructions—all occur in the implementation and its outcome. The tool’s description never reveals these issues.

Check yourselfWhat part of a tool can the model never see?

The implementation: this includes the code, where it runs, what credentials it holds, and whether it actually did what its description claims. For selecting a call, “the way the tool is implemented does not matter”11. For deciding whether to trust the call, this is the most critical part.

Section 2.4

Three layers: contract, implementation, knowledge

A vending machine mapped onto a tool. The button labels are the contract, the hidden machine is the implementation, and the taped note reading insert coin first, do not press twice, is the knowledge.refundbuttonlookupbuttoncancelbuttonmotor, coin counter,stock, wire to the bankinsert coin first,don't press twiceLABELCONTRACTname, description, input schema,result format, errorsMACHINEIMPLEMENTATIONcode, where it runs, which keyit holds, what it changesNOTEKNOWLEDGEwhen to use it, in what order,and where the traps are
A vending machine as a tool. The label is the contract, the machine is the implementation, the sticker is the knowledge.

Imagine a vending machine in a hallway. You can read its buttons, but you cannot see the motor inside. Someone has taped a note to the glass. These three elements represent the three layers of every tool.

Contract. This includes everything the model reads about a tool. Anthropic’s definition specifies a name, a description (“A detailed plaintext description of what the tool does, when it should be used, and how it behaves”), and an input_schema in JSON Schema15. For the return path, OpenAI’s tool call output “should contain a reference to a specific model tool call”16. Stanford justifies structured input and output in the same way: “Require a shared contract of how these system components will communicate”17. A contract can be incorrect on its own. OpenAI’s guide warns that toggle_light(on: bool, off: bool) “allows for invalid calls”, because nothing prevents both flags from being true16.

Implementation. This is what runs. The OpenHands agent framework separates this into a distinct class: a ToolDefinition holds the schemas and validates inputs, while a ToolExecutor contains the code that will “Execute the tool with the given action and return an observation”18. The gap between these two layers is where labels can be misleading. MCP allows a server to mark a tool as read-only, but its maintainers caution: “A server can claim readOnlyHint: true and delete your files anyway”19.

Knowledge. This is how to use the tool well: when, in what order, and where the traps are. It has no single home. Sometimes it sits in the description. When Anthropic launched Claude’s web search tool, Claude kept appending 2025 to its queries, which biased the results, and the fix was a better tool description13. Sometimes it sits in an instruction file: Claude Code’s CLAUDE.md gives “persistent context it can’t infer from code alone”4. Sometimes it sits in a skill, a folder with a SKILL.md file and optional scripts20.

A CMU lecture demonstrates why the contract is more than just the schema. REST APIs and MCP both share “Names, descriptions, and JSON Schema for structured inputs”, but they differ in how a tool is discovered, invoked, and authenticated8. The schema is the same; the rest of the contract, how the tool is found, called and authenticated, is not.

One honest note: no single source presents these three layers together. Each layer has support in the sources mentioned above; placing them side by side is this course’s synthesis.

Check yourselfThe label says refund. Name two ways the machine could still surprise you.

It could refund twice if the call is retried after a timeout (implementation). It could run with a key that can refund any customer, not just this one (implementation). It could be called before anyone checked that the order is refundable, because nobody wrote that rule down (knowledge).

Section 2.5

Capability and knowledge

Your agent can query the database, but each query it writes scans the entire table. Adding another query tool will not help. The agent already has the capability. It just does not know how to perform the action well.

This shows the difference between capability and knowledge. Anthropic draws it in one line: “MCP connects Claude to data; Skills teach Claude what to do with that data”21. Their comparison table lists what each provides: MCP offers “Tool connectivity”, while skills provide “Procedural knowledge”21.

What is missing What you see What supplies it
Capability The agent can’t do the task at all A tool
Knowledge The agent does the task, badly or in the wrong order A description, an instruction file, or a skill

CMU’s memory lecture adds two related concepts. Memory comes from the agent’s own interactions. A skill is reusable knowledge about how to act, expressed in code, text, or both22. A plan is more specific. CMU’s planning lecture states that “A plan is for this task”, unlike a skill, which “provides reusable guidance across tasks”23.

The distinction is not always perfectly clear. A skill folder might contain a scripts/ directory of executable code20. For example, Anthropic’s PDF skill includes a Python script that extracts form fields, and “because code is deterministic, this workflow is consistent and repeatable”24. So, knowledge can sometimes include small capabilities.

Where skills fit into a course is a design choice. CMU teaches them in its memory lecture22. In this course, we place them alongside tools, as one way a capability reaches an agent. This is our choice, not a widely agreed-upon standard.

Check yourselfYour agent can query the database but consistently writes slow queries. Is it missing a tool or a skill?

It is missing knowledge. The capability is present. What is missing is the understanding of how to use it effectively: which indexes exist, which tables are large, and which query patterns to avoid. This information belongs in a description, an instruction file, or a skill, not in an additional tool.

Section 2.6

What a call does: perceive, act, compute

Three bins for calls: perception reads the environment, computation transforms information without touching it, action changes the environment. One SQL tool sends a SELECT name to perception, a SELECT SQRT to computation and an INSERT to action. Only the action bin, underlined in orange, changes the world.one SQL toolPERCEPTIONreads the environmentSELECT name FROM datasearch_emailread_fileCOMPUTATIONtransforms informationSELECT SQRT(16) / 10calculatorunit conversionACTIONchanges the environmentINSERT INTO data ...send_emailmark_as_read
Three bins for calls. One SQL tool lands in all three, depending on the statement it runs.

Wang and colleagues sort what tools do into three categories: “We summarize their functions into three major categories: perception, action, and computation”12. Perception tools read the environment. Action tools change it. Computation tools transform information without touching the environment at all; “a calculator is a computation tool for mathematical calculation”12.

Their best example is a single tool that fits into every category. SQL can be computation (SELECT SQRT(16) / 10 AS result), perception (SELECT name FROM data), or action (INSERT INTO data VALUES name)12. This means the category depends on the specific call, not on the tool’s name.

Only one category changes the world. This is where the distinction between reading and writing comes from, and it is the first of the four questions we will discuss later in this chapter. The same survey reaches a clear conclusion: models that only use computation tools and never perceive or act on their environment “arguably do not fall under the category of ‘agents‘“12.

Other courses categorize this space differently. CMU asks why a tool helps: to extend the model, reaching “information or actions unavailable in the model’s parameters”, or to facilitate, delegating “operations external programs perform more reliably or efficiently”8. Its rule is: “Call tools only when their benefit outweighs latency, cost, failure, and risk”8. Toolformer, a 2023 paper that trained a 6.7-billion-parameter model to call APIs, turned a related test into a number: a call is kept if its input and output make it “easier for the model to predict future tokens”25. Google uses a broader distinction: tools let a model “know something or to do something”14.

What counts as a tool is relative. Depending on what the agent can already do, a tool might be a built-in function, an external library, or a task-specific utility12.

Check yourselfIs “search my email” perception or action? What about “mark as read”?

Search is perception: it reads the mailbox and changes nothing. Mark as read is action: it is a small change, but it alters the mailbox state that you and other programs see. This is the same email tool, but it falls into two categories, because the category depends on the call12.

Section 2.7

Who runs the tool

Three places a tool can run. A client tool runs in your application with your keys and your logs. A server tool such as web search runs on the provider's infrastructure. An agent used as a tool runs with its own model, tools and keys.model writesthe callYOUR PROCESSclient toolyour code runs it,with your keys, in your logsPROVIDERserver tool, e.g. web searchthe provider runs it;you see the result,not the runANOTHER AGENTagent used as a toolits own model, its own tools,its own keys
The same kind of contract can run in three places. Each place holds different keys and keeps different records.

Anthropic’s documentation puts it in one line: “Tools differ primarily by where the code executes”6. Client tools run in your application: the model returns a tool_use block, your code executes it, and you send back a tool_result6. Server tools such as web_search, web_fetch, code_execution and tool_search run on Anthropic’s infrastructure, and you see the results directly without handling execution, except when Claude calls one in the same group of parallel calls as one of your client tools6,26.

Google’s whitepaper identifies three types of tools. Function tools are defined by the developer and sent to the model in the request14. Built-in tools are provided by the model service; for one of these, the whitepaper notes that “The tool definition itself is invisible to the developer”14. Agent tools are entire agents: “An agent can also be invoked as a tool”14. Google’s Agent Development Kit lists the same range in its launch post, from pre-built tools and MCP tools to “other agents as tools”27.

Why does it matter where the code runs? The location determines whose machine performs the work, whose credentials it uses, and who keeps the record. A client tool runs with your keys and appears in your logs. A server tool runs on the provider’s infrastructure; you choose whether to offer it, but you do not execute it. Google’s example shows this choice: the developer includes the built-in url_context tool in the request’s tools list14. An agent used as a tool brings its own model, its own tools, and its own keys.

Check yourselfYour agent uses the provider’s built-in web search. Who performs the search, and whose records show what was retrieved?

The provider runs the search; you see the results without handling the execution6. What comes back to you is the result, and for Google’s built-in url_context tool also metadata you can inspect to see which URLs the model retrieved14. What stays with you is the decision to offer the tool at all, which you make in the request14.

Section 2.8

Four questions to ask of any tool

A tool card for send_payment with four corners. Read or write: write, money moves. Runs twice: a retry after a timeout may pay twice. Whose keys: the payment credential, and how far it reaches. Who wrote it: the tool author wrote the description and a vendor wrote the invoice it reads.send_payment(to, amount)one tool, four questions1 READ OR WRITE?write: money moves2 RUNS TWICE?a retry after a timeoutmay pay twice3 WHOSE KEYS?the payment credential;how far does it reach?4 WHO WROTE IT?description: the tool authorinvoice text: the vendor
A tool card with four corners. Fill all four before the tool goes near a real account.

Every tool, no matter its packaging or where it runs, prompts the same four questions. These questions come directly from the layers we discussed. Here they are, worked on one tool: send_payment(to, amount).

1. Read or write? This follows from what the call does, as the SQL example showed12. send_payment writes: money leaves an account. Who enforces that line? Not the model. “Permission rules are enforced by Claude Code, not by the model”32. A prompt can ask; only the harness can refuse.

2. What if it runs twice? This is the oldest question in the book. In 1984 Birrell and Nelson promised that a call that returns ran exactly once; otherwise “the procedure will have been invoked either once or not at all—the user is not told which”28. A payment call that times out may have paid. Retry it, and you may pay twice. MCP has a hint for this, idempotentHint; as OpenHands defines it after the MCP schema, it means “calling the tool repeatedly with the same arguments will have no additional effect”18. But it is only a hint. The specification says “clients MUST consider tool annotations to be untrusted unless they come from trusted servers”33.

3. Whose keys? A tool acts with someone’s credential. When an agent calls a REST API with curl, CMU’s slide warns: “Direct REST access is simple, but the agent’s shell receives the API credential”8. Anthropic’s connectors take the other route: Claude “inherits each person’s permissions from the connected service”, but “Custom connectors that use a shared credential reach whatever that credential can access”29. For send_payment, the question is whether the key can pay anyone, or only this customer’s vendors.

4. Who wrote the contract and the result? You probably did not. A server author wrote the description, and a tool poisoning attack hides “malicious instructions” in tool descriptions “that are invisible to users but visible to AI models”30. Someone else wrote the result too: the invoice text, the email, the web page the tool fetched. OpenAI’s 2023 function-calling launch post already warned that “untrusted data from a tool’s output can instruct the model to perform unintended actions”31. A 2023 security paper names the root: “LLM-Integrated Applications blur the line between data and instructions”34.

These are questions, not answers. Chapter 6 covers what to do with the answers—which writes need human approval, how to make retries safe, and how narrowly a key should be scoped.

Check yourselfFill in the four corners for send_payment.

Read or write: write; money moves. Runs twice: a retry after a timeout might pay twice, because a failed call may have run “either once or not at all”28. Whose keys: whichever payment credential the harness or server holds; you need to ask how broadly it can act29. Who wrote it: the description came from the tool’s author, and the invoice it reads came from a vendor, so both are outside your control30,31.

Section 2.9

Things that look like tools, and things that become tools

Three trays of tool-shaped calls. Control: finish(text) stops the loop and reaches nothing outside. Retrieval: search becomes a tool when the model decides whether, what and when to retrieve. Memory: reads and writes the agent issues itself, which later turns trust.CONTROLfinish(text)stops the loop;reaches nothing outsidelooks like a tool, is not oneRETRIEVALsearch(query)the model decides whether,what, and when to stopbecomes a toolMEMORYmemory_write(note)a write that later turnswill read and trustbecomes a tool
Three trays. A control action looks like a tool but goes nowhere; retrieval and memory become tools once the model decides when to use them.

Not every call that looks like a tool actually reaches the world. A CMU lecture shows finish(text), which returns the final answer and stops the loop: “This is a harness control action, not an external program”8. It has a name and an argument, like a tool, but its only job is to tell the harness to stop.

Going the other way, some things that used to be fixed steps become tools once the model decides when to use them. Retrieval is the clearest case. Stanford’s lecture puts it as “Retrieval should be an action the agent takes”, with three decisions: retrieve or answer directly, what query to issue, and whether the result is good enough35. Self-RAG (2023) trains a model that “adaptively retrieves passages on-demand”36. CRAG (2024) goes part of the way: a separate, lightweight retrieval evaluator, not the generating model, grades what came back and can trigger other retrieval actions, including web search37. Search-R1 (2025) trains the search behavior with reinforcement learning and reports relative gains of 41% and 20% over RAG baselines on seven question-answering datasets, for two Qwen2.5 models of 7 and 3 billion parameters38.

Memory follows this same pattern. MemGPT (2023) moves data between the model’s context and external storage “via function calls that are generated by the LLM processor”39. Letta’s core memory blocks “can be managed by the agent itself or by other agents” and “remain pinned to the agent’s context window”40. AgeMem, a 2026 paper, “exposes memory operations as tool-based actions” and lets the agent decide what to store, retrieve, update, summarize, or discard41. A CMU lecture sums it up: “Reads and writes are function calls the agent issues itself”22.

A memory write is a write. It changes state that a later turn, or a later session, will read and trust. Ask the four questions about it, just like any other tool.

Check yourselfIs remember this for next time a tool call? Who reads it later?

Yes, if the agent saves it through a memory tool, it is a write call22. A later turn reads it back as context. So, whoever can shape what gets written can shape what the agent does next time. This means question 4 applies to memory too.

Section 2.10

Who decides the next step

One support-ticket task drawn twice. On the left, a workflow: code fixes four steps in order, read ticket, classify, draft reply, send. On the right, an agent: the model sits in a loop and picks the next tool each time from read ticket, search docs, draft reply and send; the decision point is marked.WORKFLOW: CODE FIXES THE STEPSAGENT: THE MODEL PICKS EACH STEPread ticketclassifydraft replysendmodelpicks nextread ticketsearch docsdraft replysenddecision
One task drawn twice. On the left, code fixes every step. On the right, the model picks the next step each time.

So far the model has decided which tool to call. It does not have to. Anthropic draws the line: “Workflows are systems where LLMs and tools are orchestrated through predefined code paths”42. “Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks”42. Stanford asks the same question in its first lecture, “Who Decides the Steps?”7. In a workflow, its slide says, “code fixes the steps”, as in Agentless and AlphaCode 2; in an agent, the model decides them, as in SWE-agent7.

Both are compound AI systems, which a group of researchers writing on Berkeley’s AI research blog defined in 2024 as systems that tackle tasks “using multiple interacting components, including multiple calls to models, retrievers, or external tools”43. They framed the design question this way: should the “control logic” be written in traditional code, or “be driven by an AI model (e.g. LLM agents that call external tools)?”43. Anthropic’s advice is to start small: “we recommend finding the simplest solution possible, and only increasing complexity when needed”42.

Nothing forces one answer for a whole system. You can fix some steps in code and let the model choose others. When the model does choose, the shape of its tools matters. SWE-agent’s interface for a model user “offers a small set of simple actions for viewing, searching through and editing files” instead of a raw Linux shell44. Its authors report that interfaces tailored to language models “outperform existing user interfaces (UIs) designed for human users, such as the Linux shell”44. With GPT-4 Turbo in 2024 it solved 12.47% of 2,294 SWE-bench tasks, against a previous best of 3.8% for a non-interactive, retrieval-augmented system; that gap mixes the interface with interaction itself, so it is not a measure of the interface alone44. Those are 2024 models; the lasting point is that the interface you hand the model changes what it can do.

Check yourselfFor your Studio task, which step would you never let the model choose?

There isn’t a single right answer here. However, look for writes you cannot undo and steps that must always happen in the same order. These are good candidates to fix in code, where a hook or a workflow step runs every time, rather than leaving them to an instruction the model might skip4.

Before you go on

Close the book

Put the chapter away and try these without looking.

  1. Choose a tool from your own work or from your Studio task. Identify its three layers: what the model reads, what runs and with which key, and what knowledge it needs that was not written into the label.
  2. Ask that tool the four questions: does it read or write, what happens if it runs twice, whose keys does it use, and who wrote the contract and the result. If you cannot answer, note what information you would need to find.
  3. In one sentence, explain why writing “never do X” in a prompt is different from the harness refusing X.

Chapter two · quiz

Test yourself

Most questions have more than one right answer, so select every option that is true. Check each question, then open “Answer and why” for the reasoning.

Question 1Which of these statements about a tool call are true?Select all that apply.
Answer and why
  • RightThe model writes the tool’s name and arguments as tokens. A tool call is another token sequence the model can predict1.
  • WrongThe model runs the function and reads its return value directly. Models only take in and produce text; they have no way to call tools on their own11.
  • RightA program outside the model decides whether and how the call is executed. The model proposes; external software decides whether and how to execute8.
  • WrongWriting ‘never delete files’ in the system prompt guarantees a delete call will not run. Prompts shape what the model tries; permission rules are enforced by the harness, not the model32.
  • RightThe result returns as a message linked to the call by an ID. A tool message carries the tool_call_id of the call it answers5.
  • RightIn a workflow, code fixes the steps; in an agent, the model decides them. That is Stanford’s ‘Who decides the steps?’ distinction7.
Question 2An agent in a chat app emits a call to delete_file. Where does the authority to execute it sit?Select one.
Answer and why
  • WrongIn the model’s weights, which chose to make the call. Choosing to write a call is not executing it; the call is only text until a program acts on it1.
  • WrongIn the system prompt, which told the model which files it may touch. Instructions are advisory; hooks and permission rules are what is enforced4,32.
  • RightIn the harness that receives the call and decides whether to run it. The model proposes; external software decides whether and how to execute8.
  • WrongIn the tool’s description, which says what the tool does. The description is part of the contract the model reads; it does not run or refuse anything.
Question 3An MCP server marks a tool readOnlyHint: true, but the tool deletes files. Which layers does this failure involve?Select all that apply.
Answer and why
  • RightThe contract: the label claims the tool only reads. Annotations are part of what the client reads about the tool, and a server can lie in them19.
  • RightThe implementation: the code that runs deletes files. What actually runs is the implementation; it can differ from the label19.
  • WrongThe knowledge layer: the model was missing a usage tip. No tip would fix this; the problem is the gap between what the tool says and what it does.
  • WrongNone: this is a mistake by the model. The model can only read the label; the specification tells clients to treat annotations from untrusted servers as untrusted33.
Question 4Which of these are knowledge-layer problems?Select all that apply.
Answer and why
  • RightThe model keeps appending 2025 to its search queries, biasing the results, until the description is rewritten to explain how the tool should be used. This is a usage problem: the tool worked, the model used it badly. Anthropic fixed it by putting that knowledge into the description, which here carries knowledge as well as the contract13.
  • WrongA light-control tool accepts on=true and off=true at the same time. That is a contract problem: the schema allows invalid calls16.
  • RightThe agent runs the database migration after the tests instead of before, because the order is written down nowhere. When to use a tool and in what order is knowledge; it can live in an instruction file or a skill4,20.
  • WrongThe server behind a tool holds a credential that can read every customer’s records. That is the implementation: what runs and with whose keys29.
  • RightThe agent calls a refund tool before checking whether the order is eligible, because nobody wrote the rule down. The capability exists; what is missing is knowledge of how to use it well.
Question 5An agent can send email, but it keeps sending follow-ups to the wrong contacts because it does not know the team’s rules. Which changes address the actual gap?Select all that apply.
Answer and why
  • RightWrite the rules into a skill or an instruction file the agent loads. Skills supply procedural knowledge; MCP and tools supply connectivity21.
  • WrongAdd a second send-email tool from another provider. The agent already has the capability; another tool adds capability, not knowledge.
  • RightPut the rules about who gets follow-ups into the tool’s description. Descriptions can carry knowledge; Anthropic fixed a usage problem by improving one13.
  • WrongGive the agent an API key with wider access to the contacts system. A wider key changes the implementation and raises risk; it does not tell the agent who should get mail29.
Question 6Your agent uses a provider’s built-in web search tool. Which statements are true?Select all that apply.
Answer and why
  • WrongYour application runs the search code and returns the result. Server tools such as web_search run on the provider’s infrastructure6.
  • RightYou see the results without handling execution yourself. That is how Anthropic describes server tools6.
  • RightAnthropic says tools differ primarily by where the code executes. Tools differ primarily by where the code executes6.
  • RightFor some built-in tools, the developer never sees the tool definition. Google notes that for its built-in url_context tool the definition is invisible to the developer14.
  • WrongBecause the provider runs it, you no longer decide whether the agent has the tool. You still choose which tools to offer; Google’s example passes the built-in tool in the request’s tools list14.
Question 7Which of these calls change the world outside the model?Select all that apply.
Answer and why
  • RightINSERT INTO data VALUES name. Wang et al. use INSERT as their example of an action that modifies data12.
  • WrongSELECT name FROM data. This reads data: perception12.
  • Rightmark_as_read(message_id). It changes mailbox state that others see, so it is an action, however small.
  • Wrongfinish(‘Accra is the capital of Ghana.’). finish is a harness control action, not an external program8.
  • Rightmemory_insert(‘user prefers metric units’). Memory writes are function calls the agent issues itself, and later turns read what they store22.
  • Wrongcalculator(‘35.223 * 1.6’). A calculator is a computation tool; it neither reads nor changes the environment12.
Question 8Which statements about perception, action and computation are supported by the sources?Select all that apply.
Answer and why
  • RightOne SQL tool can serve as computation, perception or action depending on the statement. Wang et al. give SELECT SQRT, SELECT name and INSERT as the three cases12.
  • WrongWhether a call reads or writes can be read off the tool’s name. The same tool can do both; the bin belongs to the call12.
  • RightA model that only uses computation tools arguably is not an agent under Wang et al.’s definition. Their definition requires perceiving or acting on the environment12.
  • RightToolformer kept an API call when its input and output made future tokens easier to predict. That was its filtering criterion, on a 2023 model25.
  • WrongIn CMU’s terms, delegating arithmetic to a calculator extends the model. Delegating work a program does more reliably is facilitate; extend means reaching information or actions the model lacks8.
Question 9You are reviewing a refund tool before it goes live. Which of these are among the four questions this chapter asks of every tool?Select all that apply.
Answer and why
  • RightDoes it read or write? Read or write follows from what the call does12.
  • RightWhat happens if it runs twice? A failed remote call may have run once or not at all28.
  • RightWhose keys does it act with, and how far do they reach? A shared credential reaches whatever that credential can access29.
  • RightWho wrote its description and its results? Descriptions can hide instructions, and tool output can instruct the model30,31.
  • WrongDoes its description promise that retries are safe? That is a claim by the tool’s author, not one of the four questions; a hint such as idempotentHint must be treated as untrusted unless the server is trusted33.
Question 10A send_payment call times out and no result comes back. What can you conclude from the timeout alone?Select all that apply.
Answer and why
  • RightThe payment may have gone through once, or not at all. Since 1984: a failed call ran either once or not at all, and the caller is not told which28.
  • WrongThe payment did not go through, so a retry is safe. A retry after a call that did run would pay twice28.
  • WrongIf the server marked the tool idempotentHint: true, a retry is guaranteed safe. Annotations are hints; clients must treat them as untrusted unless the server is trusted33.
  • WrongThe model can tell from the timeout message whether the money moved. A missing reply does not tell you whether the server crashed or the network failed, let alone whether the payment ran28.

Sources

  1. CMU 11-768 Lecture 1: What Are Agents? And How Do They Work?. Daniel Fried, Graham Neubig. www.cmu-agents.com/slides/lecture-01-agents.pdf ↗
  2. Artificial Intelligence: A Modern Approach (4th ed.), ch. 2 Intelligent Agents. Russell & Norvig (Pearson).
  3. Young. "Effective Harnesses for Long-Running Agents." Anthropic (2025).. www.anthropic.com/engineering/effective-harnesses-for-long-running-agents ↗
  4. Anthropic. "Claude Code: Best Practices for Agentic Coding." (2025).. www.anthropic.com/engineering/claude-code-best-practices ↗
  5. OpenAI Chat Completions API. platform.openai.com/docs/api-reference/chat/create ↗
  6. Tool use with Claude - Claude Platform Docs. Anthropic. platform.claude.com/docs/en/agents-and-tools/tool-use/overview ↗
  7. Stanford CS329Z Lecture 1: Intro to Agentic Systems. Diyi Yang, Michael Ryan, John Yang. web.stanford.edu/class/cs329z/slides/lecture01.pdf ↗
  8. Tool Use for Language Model Agents (Lecture 2 slides). CMU LTI / Graham Neubig. www.cmu-agents.com/slides/lecture-02-tool-use.pdf ↗
  9. Yao et al. "ReAct: Synergizing Reasoning and Acting in Language Models." ICLR (2023).. arXiv (Yao et al.). arxiv.org/abs/2210.03629 ↗
  10. Mini-SWE-Agent. github.com/swe-agent/mini-swe-agent ↗
  11. What are Tools?. Hugging Face. huggingface.co/learn/agents-course/en/unit1/tools ↗
  12. What Are Tools Anyway? A Survey from the Language Model Perspective. Wang, Cheng, Zhu, Fried, Neubig. arxiv.org/abs/2403.15452 ↗
  13. Writing effective tools for AI agents—using AI agents. Anthropic. www.anthropic.com/engineering/writing-tools-for-agents ↗
  14. Agent Tools & Interoperability with MCP (whitepaper PDF, mirrored). Google (Styer, Patlolla, Mohan, Diaz). github.com/sameeerjadhav/google-agents-resources ↗
  15. Define tools. Anthropic. platform.claude.com/docs/en/agents-and-tools/tool-use/implement-tool-use ↗
  16. OpenAI Function Calling Guide. OpenAI. developers.openai.com/api/docs/guides/function-calling ↗
  17. Stanford CS329Z Lecture 2: LLMs for Builders. Diyi Yang, Michael Ryan, John Yang. web.stanford.edu/class/cs329z/slides/lecture02.pdf ↗
  18. OpenHands ToolDefinition Source. github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/tool/tool.py ↗
  19. Tool Annotations as Risk Vocabulary: What Hints Can and Can't Do. Model Context Protocol Blog (Ola Hungerford, Sam Morrow/GitHub, Luca Chang/AWS). blog.modelcontextprotocol.io/posts/2026-03-16-tool-annotations ↗
  20. Agent Skills specification. agentskills.io. agentskills.io/specification ↗
  21. Skills explained: How Skills compares to prompts, Projects, MCP, and subagents. Anthropic (Claude blog). claude.com/blog/skills-explained ↗
  22. Memory and Skills (Lecture 4 slides). CMU / Daniel Fried. www.cmu-agents.com/slides/lecture-04-memory-and-skills.pdf ↗
  23. CMU 11-768 Lecture 5: Planning and Task Decomposition. 11-768 staff. www.cmu-agents.com/slides/lecture-05-planning.pdf ↗
  24. Equipping agents for the real world with Agent Skills. Anthropic. www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills ↗
  25. Toolformer: Language Models Can Teach Themselves to Use Tools. arXiv (Schick et al.). arxiv.org/abs/2302.04761 ↗
  26. Claude Platform 101. Anthropic Academy. anthropic.skilljar.com/claude-platform-101 ↗
  27. Agent Development Kit: Making it easy to build multi-agent applications. Google for Developers Blog. developers.googleblog.com/en/agent-development-kit-easy-to-build-multi-agent-applications ↗
  28. Implementing Remote Procedure Calls (Birrell & Nelson), ACM TOCS 2(1). ACM Transactions on Computer Systems (copy hosted at cmu.edu). www.cs.cmu.edu/~dga/15-712/F07/papers/birrell842.pdf ↗
  29. Use connectors to extend Claude's capabilities. Anthropic (Claude Help Center). support.claude.com/en/articles/11176164-use-connectors-to-extend-claude-s-capabilities ↗
  30. MCP Security Notification: Tool Poisoning Attacks. Invariant Labs. invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks ↗
  31. Function calling and other API updates. OpenAI. openai.com/index/function-calling-and-other-api-updates ↗
  32. Configure permissions (Claude Code). Anthropic. code.claude.com/docs/en/permissions ↗
  33. Tools - Model Context Protocol (spec version 2026-07-28, latest). Model Context Protocol (LF Projects). modelcontextprotocol.io/specification/latest/server/tools ↗
  34. Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection. Greshake et al. (2023). arxiv.org/abs/2302.12173 ↗
  35. Stanford CS329Z Lecture 3: RAG + Agents. Diyi Yang. web.stanford.edu/class/cs329z/slides/lecture03.pdf ↗
  36. Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection. Asai et al. (2023). arxiv.org/abs/2310.11511 ↗
  37. Corrective Retrieval Augmented Generation (CRAG). Yan et al. (2024). arxiv.org/abs/2401.15884 ↗
  38. Search-R1: Training LLMs to Reason and Leverage Search Engines with RL. Jin et al. (2025). arxiv.org/abs/2503.09516 ↗
  39. Packer et al. "MemGPT: Towards LLMs as Operating Systems." arXiv (2023).. arxiv.org/abs/2310.08560 ↗
  40. Letta. "Agent Memory: How to Build Agents that Learn and Remember." Letta Blog (2025).. www.letta.com/blog/agent-memory ↗
  41. AgeMem. aclanthology.org/2026.acl-long.981 ↗
  42. Schluntz & Zhang. "Building Effective Agents." Anthropic (2024).. Anthropic. www.anthropic.com/engineering/building-effective-agents ↗
  43. Zaharia et al. "The Shift from Models to Compound AI Systems." BAIR Blog (2024).. bair.berkeley.edu/blog/2024/02/18/compound-ai-systems ↗
  44. Yang et al. "SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering." NeurIPS (2024).. arxiv.org/abs/2405.15793 ↗