Consider the tool server from chapter 4: one tool searches the course catalog, another reads a syllabus, and a third posts a question to the class forum. You have not written a handler yet, but you have already made five decisions. You decided what actions exist, how many actions the model sees at once, which calls need a gate, whose text can reach the posting tool, and how the tools are packaged. Most teams make these five decisions by accident. In this chapter, we make them on purpose, one at a time. We test each decision with a single question: would it still matter if the model were ten times better?
Section 9.1
The ruler: what would a better model change?
Chapter 1 handed you Yan Wang’s ruler, so here is the short version. In his October 2 guest lecture he said “Every hot noun bundles a lasting problem with packaging from its year”1. He separates the two with two questions: “If the model were 10x better, would this still matter?” and “What problem is it actually solving, and do I still have it?”1 Understanding a lasting problem “appreciates”; packaging “depreciates”1.
In chapter 1 we pointed the ruler at protocols. Here we point it at decisions, and the same deck shows why that works. When Yan Wang split LangChain, the lasting problem he named was “Deciding what the model sees, what it may do, when it stops, and when to ask a human”1. His note under it reads: “The loop is short; these decisions are the work”1. Those are this chapter’s judgments. What the model sees is judgments 1 and 2. What it may do, and when a human is asked, are judgments 3 and 4. How the tool reaches the model at all is judgment 5.
His essays add a map for where the judgments live. He splits putting a model into a product into four layers: model, protocol, runtime and contract2. The protocol layer asks questions such as “MCP or RESTful API?”, and the contract layer asks “What does success actually look like?”2. Most packaging sits in the protocol layer. Most of this chapter’s judgments sit in the runtime layer, where tools get invoked, and in the contract layer, where you decide what counts as safe and done. His contract layer is about success criteria; it is not the tool contract from chapter 2, which judgments 1 and 2 below refer to.
He also offers a habit to keep a judgment once you have made it: “externalize first, then execute”3. Each new chat “starts from a blank slate plus your prompt”3. A decision your team made but did not write down will likely be made again next week, possibly differently.
Each judgment below has four parts, in the same order: the decision, the layer and property it changes, the evidence, and the 10x verdict. The verdicts are specific to this course. They are judgments, not measurements. Each comes with a reason you can check against the evidence and discuss.
Check yourselfYour team debates whether to expose your server over MCP or as plain REST. Where does this fit within Yan Wang’s four layers? Does it pass the first question?
This is a protocol-layer question. It mostly fails the first question: a better model does not care which wire format carried the definition. What remains is the lasting problem underneath, “Giving agents clear, safe interfaces and deciding what plain code should handle”1.
Section 9.2
Judgment 1: which actions to give the model
Your support app shows a customer’s order on screen, and the user asks for a refund. You could give the model a tool that takes an order ID. OpenAI’s function-calling guide says not to: “Don’t make the model fill arguments you already know”4. Its example is to define submit_refund() with no parameters and pass the order ID in your code, and the same passage adds: “Combine functions that are always called in sequence”4.
The decision. Design actions for the task itself, not for the API. Keep work that code can do reliably within your code. For each tool, ask if the agent truly needs it.
The layer and property. This is the contract, the part of the tool the model reads (chapter 2). The property it sets is what the model can do at all. Every argument the model fills is a value it can get wrong. Every tool it holds is a door it can open.
The evidence. Anthropic describes a tool as “a contract between deterministic systems and non-deterministic agents”5: the caller might skip the tool, misuse it, or “hallucinate”5. This is why we move certain work into code. Anthropic’s advice on agents points the same way: “we recommend finding the simplest solution possible, and only increasing complexity when needed”6. The Claude Code team keeps about 20 tools and says “The bar to add a new tool is high, because this gives the model one more option to think about”7. The shape of the actions also changes results. SWE-agent’s authors gave a model “a small set of simple actions for viewing, searching through and editing files” and report that interfaces built for language models “outperform existing user interfaces (UIs) designed for human users, such as the Linux shell”8. Those are 2024 models (chapter 2 gives the numbers). Sierra states the security side plainly: “The best way to make sure that an agent can’t do something unexpected with sensitive data is to avoid giving it that data in the first place”9.
The 10x verdict: still matters. A better model chooses better among the actions you provide. It does not reduce the scope of what those actions can reach. The action set determines the blast radius—how much damage one wrong call can do—and that is a property of your system. One honest limit: specific tools do expire. The Claude Code team writes that “As model capabilities increase, the tools that your models once needed might now be constraining them”7. The tool list changes over time; you still have to decide what goes on it.
Check yourselfYour API has cancel_order(order_id) and refund(order_id). In your business, every cancellation is followed by a refund. The order is already on screen. What do you give the model?
One tool, such as cancel_and_refund(), with the order ID passed by your code. Both rules from the same guide apply here: merge functions always called in sequence, and don’t make the model fill arguments you already know4.
Section 9.3
Judgment 2: how much the model sees at once
Connect five common MCP servers, for GitHub, Slack, Sentry, Grafana and Splunk, and Anthropic’s documentation says their definitions “can consume ~55k tokens” before Claude does any work10. The model must read this menu before each choice it makes.
The decision. Show the model the smallest set of tools that can do the job. First, subtract tools you don’t need. Then, merge tools that always go together, and group tools by domain. Only after these steps should you load tools on demand or let the model call them from code. Chapter 5 covers all four of these moves.
The layer and property. This is the contract again, but now it’s about what fills the context. The property is what the model sees at one time.
The evidence. Longer menus make selection harder. RAG-MCP reports that retrieving only the relevant tool descriptions “more than triples tool selection accuracy (43.13% vs 13.62% baseline)” on its benchmark tasks11. ToolMenuBench, across seven model backends, reports task success rising from 32.1% when every tool is visible to 85.7% when using its filter, with about 98% fewer tokens12. Anthropic states “Claude’s ability to pick the right tool degrades once you exceed 30–50 available tools”10. OpenAI’s guide says “Aim for fewer than 20 functions available at the start of a turn at any one time, though this is just a soft suggestion”4, and it suggests namespaces of “fewer than 10 functions”13. None of these vendors publishes the evaluation data behind its numbers, and each offers guidance specific to its own models4,10. A Studio tool server with three to eight tools is below the thresholds these vendors provide, and Anthropic itself says standard tool calling “is a better fit when you have fewer than 10 tools”10.
The 10x verdict: half and half. One half may shrink. Anthropic’s internal evaluation of tool search shows how much the baseline moved between models: without tool search, Opus 4 scored 49% and Opus 4.5 scored 79.5%14. A stronger model may pick well from a longer list. The other half stays, because it describes your system, not the model. Function definitions “count against the model’s context limit and are billed as input tokens”4. In Anthropic’s prompt cache, changing tool definitions “invalidates the entire cache”15, which is why OpenAI’s tool search adds newly found tools “at the end of the context window”13. And every visible tool can be misused: ToolMenuBench counts “risky-tool exposure” as a cost of its own12. A smarter model pays the same bill, and the tool it should never have seen is still within reach.
Check yourselfYour Studio server has six tools. A teammate wants to add tool search “to be safe”. What do you say?
Six tools is below every vendor threshold discussed in this chapter. Anthropic says standard tool calling works better with fewer than 10 tools10. Tool search would add a moving part without solving an existing problem. First, measure selection on your own tasks (chapter 8), and then revisit this decision when your list of tools grows.
Section 9.4
Judgment 3: who decides this step
In July 2025, Replit’s CEO wrote that its “agent in development deleted data from the production database” and called it “Unacceptable and should never be possible”18. A user affected by this wrote a separate complaint. They said that during a code freeze, the agent kept changing code “Despite repeated explicit instructions—including eleven separate warnings in ALL CAPS”19. The same account concludes: “Enforcing a true code freeze was simply impossible within Replit’s architecture”19. Keep these two points separate: the user’s account states the warnings were about the freeze, not the database19. Both failures teach the same lesson.
The decision. Let reads pass. Send every write through a gate in your code. Give every write tool an answer to one question: what if it runs twice?
The layer and property. This is the harness (chapter 2). The property is who decides whether a requested call runs.
The evidence. Claude Code’s documentation draws the line: “Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or CLAUDE.md shape what Claude tries to do, but they don’t change what Claude Code allows”20. Its rules are checked in a fixed order, “deny, then ask, then allow”20, and a hook that exits with code 2 blocks a call even if its own output says allow21. Replit’s fixes were structural in the same way: “automatic DB dev/prod separation to prevent this categorically” and a “one-click restore” from backups18. OpenAI keeps the same line when the model writes code: for “Writes or approval-sensitive actions”, its guide says “Use direct tool calling by default to preserve a clear authorization boundary”22.
Then there is the second half of the decision. In 1984, Birrell and Nelson wrote that a failed remote call “will have been invoked either once or not at all—the user is not told which”16. As of October 2026, the tool-calling guides from OpenAI, Anthropic and Google, searched in full as fetched on October 3, say nothing about what to do when a call may already have run or may run twice4,23,24,25. That part is left to you. An old answer exists. RFC 1057, the 1988 Sun RPC specification, says a server “may choose to remember this ID after executing a call and not execute calls with the same ID”17.
The 10x verdict: fully matters. A smarter caller still cannot undo a write. It still cannot see whether a lost call ran, because the reply never arrived. It can also be wrong about its own actions. After the Replit deletion, the agent “initially denied that rollback functionality existed”19. The gate has to sit where the model’s judgment cannot move it.
Check yourselfYour posting tool times out, and the agent retries. What can go wrong? What would you change?
The question may be posted twice: a call that failed may have run “either once or not at all”16. Give each post an ID that your server remembers. Refuse a second post with the same ID, the way Sun RPC servers could skip a repeated transaction ID17. Posting stays a write, so it also goes through the harness’s gate.
Section 9.5
Judgment 4: whose words can steer which action
In 2025, Invariant Labs put instructions in an issue on a public GitHub repository27. A user’s agent, connected through GitHub’s MCP server to an account that could also read private repositories, read the issue while handling a normal request27. It could then be “coerced into pulling private repository data into context, and leaking it in an autonomously-created PR in the public repository”27. The researchers emphasize that “this is not a flaw in the GitHub MCP server code itself”27.
The decision. Treat anything a tool returns as data, never as an instruction. Do not let one session hold private data, untrusted content, and a way to send data out at the same time.
The layer and property. This is about the harness and scope of a session. The property is whose words count. Chapter 2’s fourth question asked who wrote the contract and the result. This judgment is what you do with that answer.
The evidence. OpenAI’s 2023 launch post for function calling already warned that “untrusted data from a tool’s output can instruct the model to perform unintended actions”28. A 2023 paper identifies the cause: “LLM-Integrated Applications blur the line between data and instructions”29. Simon Willison explains why the model cannot resolve this alone: “LLMs are unable to reliably distinguish the importance of instructions based on where they came from”26. His lethal trifecta consists of private data, exposure to untrusted content, and the ability to send data out. With all three, he writes, “an attacker can easily trick it”26.
Dialogs did not hold. Claude Desktop asks before each call by default, but “many users already opt for an ‘Always Allow’ confirmation policy”27, and in Cursor the arguments sat “hidden behind an overly simplified UI representation”30. Structure did hold. Invariant’s fix is a policy that allows one repository per session27. Sierra hands its agent “a separate GitHub token that only gives read-only access to specific repositories”9. The CaMeL defense separates the plan from untrusted data and reports 77% of AgentDojo tasks solved “with provable security”, against 84% for an undefended system31. That is a real cost in capability, paid on purpose.
Vendors now incorporate this rule into products. Claude Managed Agents’ automatic evaluator “does not read intent from a tool result, a fetched webpage, an MCP server’s response, or a message between session threads”32, but end-user text you relay in user messages counts as your intent32.
The 10x verdict: fully matters. A better model still reads one stream of tokens: “Everything eventually gets glued together into a sequence of tokens and fed to the model”26. An attacker only needs one success. This is why Willison, discussing guardrail products that claim to stop 95% of attacks, says that in web application security that number is “very much a failing grade”26. In the cases in this chapter, prompts and dialogs failed, but structural limits held.
Check yourselfYour new agent reads incoming support emails, can query the customer database, and can send replies. Which of the three legs is involved, and which would you remove first?
All three are involved: emails are untrusted content, the database is private data, and replies are a way out26. Removing a leg could mean drafting replies for a human to send, or limiting the database query to only the sender’s own records. There is no single correct answer, but the change must be structural, not a prompt asking the model to be careful.
Section 9.6
Judgment 5: which packaging
Chapter 4 discussed this judgment when we looked at what a packaging adds beyond a local function. Here is a short version, placed next to the other four judgments.
The decision. Begin with the simplest packaging that works for the agents using the tool. Add an MCP server when several hosts need the same tool, or when a server must hold a credential that the agent should never access.
The layer and property. This refers to packaging, and the property describes how the tool reaches the harness and where its credentials are stored.
The evidence. CMU’s tool-use lecture states “MCP is an alternative agent-facing interface—not a requirement for calling REST APIs”33. When MCP truly adds value, it is through credential brokering: “the server accepts one credential and uses a different credential upstream. The model sees neither secret”33. A commenter in a Hacker News discussion about CLIs versus MCP made this same point: “Authorization, in my opinion, is the big problem you need MCP for”34. If you do build a server, FastMCP’s documentation warns that models do “significantly better” with curated servers “than with auto-converted OpenAPI servers”35, though it offers no benchmark. Yan Wang’s default approach is a sequence: “Start with a CLI and an instruction file; add MCP when distribution requires it”1.
The 10x verdict: mostly packaging, but the switching cost is real. A better model does not care much which format carried the definition. You still pay to change between packagings. The 2026-07-28 MCP revision removed protocol sessions and the opening handshake36, and one partner quoted in the release said “The biggest changes are breaking ones”37. The same revision notes that a client whose response stream breaks “MUST re-issue it as a new request with a new request ID”36. Packaging details can reach back into judgment 3: if the lost request was a write that already ran, the re-issued one arrives with a new request ID, so only your own tool-level ID can catch the repeat.
Check yourselfThree teams’ agents, running in two different hosts, need your catalog tools. The posting tool requires a forum key that no agent should hold. Should you use a CLI, a local function, or an MCP server?
Section 9.7
At company scale
Cloudflare describes an LLM as “the most brilliant and enthusiastic junior hire you’ve ever had”, and today’s decentralized approach to MCP as “giving that junior hire a master key to every office and server room on their first day”39. One developer can make the five judgments in their own code. A company with hundreds of agents needs them made once, in one place.
The decision. Put the judgments in one shared gateway, review every server before anyone can use it, and let identity follow the work.
The evidence. A listing is not a review. The MCP Registry “hosts metadata that points to those packages”, and its metadata is “deliberately unopinionated”38; maintainers “can manually remove spam or malicious servers” after the fact38. Sierra built one gateway; by its July 2026 post, 89% of its employees used it to connect agents to 45 services9. It keeps an audit log, blocks access to sensitive data about more than one customer in a session, and requires approval out of band when someone has a legitimate reason to cross that line9. Its rule for identity: “Interactive work runs as the user. Scheduled or shared workflows run as service accounts with only the permissions they need”9. Cloudflare’s launch post describes portals where “Administrators can now review and approve MCP servers before making them available to users”, and where users sign in with the corporate identity provider39. Cloudflare’s post also concedes a gap: the portal does not yet fully prevent direct access, around the portal, to a server that has no authorization of its own39. Chapter 7 covers these patterns in more detail.
The 10x verdict: fully matters. Who may use which tool, with whose identity, and who can audit it afterward are facts about your organization. A better model changes none of them.
Check yourselfImagine a teammate finds a server in the MCP Registry. They want to add it to your company gateway today. What should the listing tell you? What still needs to happen?
Section 9.8
The five on one page, and what comes next
Look at the verdict column. The two rows that fully matter, who decides a step and whose words can steer it, are the ones where the cases in this chapter were decided by structure: a gate in code, a session bound to one repository. The row that is mostly packaging is the one most likely to change, as the 2026 MCP revision demonstrated. When you have limited time, focus on rows 3 and 4.
This lecture focuses on a single agent and its tools. We will cover splitting a task across multiple agents in the next two lectures. CMU’s planning lecture shows an agent calling launch_subagent(goal) to run a copy of itself on a subtask, and notes that “Delegation is an action, so it can be trained”40. One type of orchestration begins with a plan that a person reviews: “Cursor, Claude Code, and Codex all introduced a Plan Mode: write a persistent plan, have a human verify it, carry it out (possibly with subagents, in parallel)”40. Lectures 6 and 7 will address sub-agents and their orchestration. Chapter 6 of this book shows how a plan can also function as a security boundary. We will also discuss memory later. CMU distinguishes memory, which is saved from an agent’s own interactions, from a skill, which is reusable knowledge about how to act41. Chapter 2 already showed that a memory write is a write, so the five judgments apply to it.
Check yourselfSuppose your agent hands a long research subtask to a copy of itself. Which of this chapter’s judgments still apply, and what concepts will we cover later?
All five judgments still apply to the tools each copy holds: what it can do, what it sees, who gates its writes, whose text reaches it, and how its tools arrive. How to split the work and how the copies coordinate are questions for Lectures 6 and 7.
Before you go on
Close the book
- For your Studio tool server, write the five decisions as one line each, then add the 10x verdict for each, with your own reason.
- Pick the riskiest of the five for your server. Name the structural limit you would put in code for it, and say which incident in this chapter it answers.
- A teammate says the models are getting better, so the write gate can go. Explain in three sentences why judgments 3 and 4 do not depend on the model.
Chapter nine · 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.
Sources
- What Gets You Hired, What Gets You Promoted, and What AI Changed. Yan Wang guest deck. ai-builders.com/resources/w4995 ↗
- From Process Certainty to Outcome Certainty. Yan Wang. yage.ai/result-certainty-en.html ↗
- Write the Skill Before You Execute. Yan Wang. yage.ai/skill-first-en.html ↗
- OpenAI Function Calling Guide. OpenAI. developers.openai.com/api/docs/guides/function-calling ↗
- Writing effective tools for AI agents—using AI agents. Anthropic. www.anthropic.com/engineering/writing-tools-for-agents ↗
- Schluntz & Zhang. "Building Effective Agents." Anthropic (2024).. Anthropic. www.anthropic.com/engineering/building-effective-agents ↗
- Seeing like an agent. Anthropic (Thariq Shihipar). claude.com/blog/seeing-like-an-agent ↗
- Yang et al. "SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering." NeurIPS (2024).. arxiv.org/abs/2405.15793 ↗
- Building Sierra's MCP Gateway: An engineering iceberg. Sierra (Mihai Parparita). sierra.ai/blog/building-sierras-mcp-gateway-an-engineering-iceberg ↗
- Tool search tool - Claude Platform Docs. Anthropic. platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool ↗
- RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation [round-1 C18]. Gan & Sun (arXiv). arxiv.org/abs/2505.03275 ↗
- ToolMenuBench: Benchmarking Tool-Menu Filtering Strategies for Reliable and Efficient LLM Agents. arXiv (Suresh Babu & Ganesh Iyer; authors state personal capacity). arxiv.org/abs/2606.15508 ↗
- Tool search | OpenAI API. OpenAI. developers.openai.com/api/docs/guides/tools-tool-search ↗
- Introducing advanced tool use on the Claude Developer Platform. Anthropic. www.anthropic.com/engineering/advanced-tool-use ↗
- Prompt caching - Claude Platform Docs. Anthropic. platform.claude.com/docs/en/build-with-claude/prompt-caching ↗
- 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 ↗
- RFC 1057: RPC: Remote Procedure Call Protocol Specification Version 2. Sun Microsystems / RFC Editor. www.rfc-editor.org/rfc/rfc1057.txt ↗
- Post by @amasad (Replit CEO). Amjad Masad / Replit. x.com/amasad/status/1946986468586721478 ↗
- Replit's New Release Addressed Most of The Challenges We Hit Vibe Coding. But Is 'Prosumer' Vibe Coding Really Ready for Commercial Apps Yet?. SaaStr (Jason Lemkin, first-hand). www.saastr.com/replits-new-release-address-most-of-the-challenges-we-hit-vibe-coding-but-is-prosumer-vibe-coding-really-ready-for-commercial-apps-yet ↗
- Configure permissions (Claude Code). Anthropic. code.claude.com/docs/en/permissions ↗
- Claude Code hooks reference. Anthropic. code.claude.com/docs/en/hooks ↗
- Programmatic Tool Calling. OpenAI. developers.openai.com/api/docs/guides/tools-programmatic-tool-calling ↗
- Tool use with Claude - Claude Platform Docs. Anthropic. platform.claude.com/docs/en/agents-and-tools/tool-use/overview ↗
- Function calling with the Gemini API - Interactions API | Google AI for Developers. Google. ai.google.dev/gemini-api/docs/function-calling ↗
- Define tools. Anthropic. platform.claude.com/docs/en/agents-and-tools/tool-use/implement-tool-use ↗
- The lethal trifecta for AI agents: private data, untrusted content, and external communication. Simon Willison. simonwillison.net/2025/Jun/16/the-lethal-trifecta ↗
- GitHub MCP Exploited: Accessing private repositories via MCP. Invariant Labs. invariantlabs.ai/blog/mcp-github-vulnerability ↗
- Function calling and other API updates. OpenAI. openai.com/index/function-calling-and-other-api-updates ↗
- 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 ↗
- MCP Security Notification: Tool Poisoning Attacks. Invariant Labs. invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks ↗
- Defeating Prompt Injections by Design (CaMeL). arXiv (Debenedetti, Shumailov, Fan, Hayes, Carlini, Fabian, Kern, Shi, Terzis, Tramer; Google/DeepMind/ETH). arxiv.org/abs/2503.18813 ↗
- Permission policies (Claude Managed Agents). Anthropic (Claude Platform Docs). platform.claude.com/docs/en/managed-agents/permission-policies ↗
- Tool Use for Language Model Agents (Lecture 2 slides). CMU LTI / Graham Neubig. www.cmu-agents.com/slides/lecture-02-tool-use.pdf ↗
- When does MCP make sense vs CLI?. Hacker News. news.ycombinator.com/item?id=47208398 ↗
- FastMCP OpenAPI Integration. gofastmcp.com/integrations/openapi ↗
- MCP specification 2026-07-28: Key Changes. Model Context Protocol. modelcontextprotocol.io/specification/2026-07-28/changelog ↗
- MCP 2026-07-28 Specification Release. MCP Blog (D. Soria Parra, D. Delimarsky, Lead Maintainers). blog.modelcontextprotocol.io/posts/2026-07-28 ↗
- The MCP Registry - Model Context Protocol. Model Context Protocol. modelcontextprotocol.io/registry/about ↗
- Securing the AI Revolution: Introducing Cloudflare MCP Server Portals. Cloudflare. blog.cloudflare.com/zero-trust-mcp-server-portals ↗
- CMU 11-768 Lecture 5: Planning and Task Decomposition. 11-768 staff. www.cmu-agents.com/slides/lecture-05-planning.pdf ↗
- Memory and Skills (Lecture 4 slides). CMU / Daniel Fried. www.cmu-agents.com/slides/lecture-04-memory-and-skills.pdf ↗