MindRoom: tools split by read and write, not by endpoint
How Bas Nijholt halved MindRoom's tool schemas and kept small models accurate, for builders who own their agent's tools.
Say you run a two-person automation shop and you've built a client assistant on your own agent harness. You wired in Gmail, GitHub and Slack the quick way: each REST endpoint became one tool, about 80 in all. On a frontier model it mostly works. The client wants a local model for privacy, though. On that model every request carries thousands of tokens of schemas before anyone types a word, and prefill drags. A colleague suggests collapsing everything into one big tool per service. That would shrink the schemas, but your client also asked for an agent that can read mail and must ask before sending, and one tool per service would put reads and writes behind the same name.
Designing tools for the model, instead of mirroring the API you already had, removes most of that cost without the mega-tool trap. In a post dated November 28, 2026, Bas Nijholt describes redesigning all 155 built-in toolkits in MindRoom. Default functions went from 729 to 298 and total tool schemas shrank by 50%. On his GitHub benchmark, pooled across four small open-weight models and a hosted reference model, the redesigned shape matched the old one at a third of the prompt tokens.
What it is
A set of tool-design rules, each with a measurement behind it, from one developer who owns every toolkit in his harness. Nijholt's starting point: every tool schema travels with the conversation on every turn, so the shape of the schema is a cost you pay repeatedly. MindRoom's toolkits had looked like auto-converted REST APIs, with GitHub, Gmail and Docker exposing twenty to forty functions each. Mapped to the shop above:
- Group verbs under an
actionparameter. Instead ofread_email,write_email,save_draft,star_emailandarchive_email, each repeatingto,message_idandsubject, you describe oneemail(action, ...)tool and pay for the shared arguments once. Across the catalog that cut defaults from 729 to 298 functions while keeping all 39 GitHub actions. Per the post's footnotes, the full GitHub toolkit schema MindRoom ships went from 6,670 to 1,658 tokens once all the week's changes landed. That addresses the prefill drag. - Then split reads from writes. Nijholt first considered one mega-tool per toolkit and calls that a bad idea, because permissions and approvals live at the function boundary. A read-only agent should simply not be given the write function. He split four built-in mega-tools into read and write functions, and split GitHub into five: two reads and three write tiers, so issue comments sit apart from repository deletes. That is the client's read-but-ask-before-send requirement, enforced in code.
- Drop the redundant null. A Python parameter like
limit: int | None = Nonemakes standard JSON-schema generators emit ananyOfwith anullbranch. Nijholt changed MindRoom's generator to emit the plain type when the default isNone, still accepting an explicitnullat runtime.anyOfblocks across the catalog fell 71%, and a five-model check on optional-heavy calls scored 40/40 before and after. Parameters wherenullmeans something, like a SQL limit where null returns all rows, stay as they were. - Say shared things once. Two helper arguments MindRoom adds to every tool cost nearly a hundred tokens per tool in repeated descriptions. Explaining them once in the system prompt cut that overhead by almost three quarters.
- Prefix integration names. At the start of the week 47 function names collided across the catalog, so enabling two integrations silently shadowed one. Prefixing as
<toolkit>_<verb>took that to zero.
The benchmark is the part to copy. Nijholt argues that frontier models get almost any tool call right, so a test suite that scores 20/20 gives no signal. He ran 400 trials: 20 GitHub tasks, four consumer-scale open-weight models plus gpt-5-mini as a hosted reference, and four schema shapes covering the same 39 operations. He reports the five read/write functions tied the 39-function REST layout at 93/100 exact first-try passes using a third of the prompt tokens (1,488 tokens against 4,480 in the benchmark's schemas, which strip MindRoom's harness parameter so only the API shape is compared). Two functions dropped to 83% and one mega-tool to 79%, while saving only a couple hundred more tokens. The failure logs showed why. A merged tool's parameter list grows to the union of every action, 42 parameters in the single-tool arm, so small models pass the wrong action's arguments. Its required list shrinks to the intersection, so models drop arguments that used to be mandatory. gpt-5-mini stayed at 95 to 100% on every shape, which would have hidden the 14-point drop.
The guidance from vendors points the same way. P99Log's survey of OpenAI, Anthropic, Google and MCP guidance, from November 13, 2026, recommends designing around workflows over endpoints, namespacing names such as asana_search and jira_search, and using enums wherever valid values are limited. It also notes GitHub cut its MCP server's default from 101 tools and 64.6k tokens to 52 tools and 30.3k tokens in October 2025.
Nijholt also tested the objection that prompt caching makes schema tokens free. Across 345,924 of his own requests over seven days, 91.8% of tokens were cache reads, yet input and cache tokens still made up 81% of spend, by his count.
Alternatives, each from its own source:
- One shell tool. For pure coding tasks it used far fewer tokens than a full toolset in Nijholt's tests, but he says it makes per-action approval and credential handling hard.
- Toolsets or tool search. Enable only the groups a task needs, or give the model a tool that finds other tools. P99Log reports Anthropic's Tool Search Tool cut context use by about 85% in its example; toolsets are the simplest option and work when you can predict what a task needs.
- Cloudflare's search-and-execute server. cloudflare/mcp exposes about 2,500 Cloudflare API endpoints in roughly 1,100 tokens by having the model write JavaScript against the spec, at the cost of running generated code in isolated Workers.
- Anthropic's programmatic tool calling. According to SayBackend's walkthrough, Anthropic's numbers show about 38% fewer billed input tokens on a 75-tool benchmark with no accuracy change, and about 8% more cost on 蟿虏-bench, where each turn makes one or two calls.
Who it's for
Pick this up if you run your own harness or own the MCP servers your agent uses, if you connect more than a handful of integrations, and especially if you target local or small hosted models. Nijholt says smaller schemas matter most as a share of the bill on shorter loops, fresh subagents, cold cache writes and local models where every extra thousand tokens slows prefill. It also fits anyone who needs approval gates on writes, since the read/write split does that in code.
Skip it, or start elsewhere, if your agent does pure coding through a shell, where Nijholt's own tests favoured a single shell tool. Skip it if you consume vendor MCP servers you can't edit; toolsets or tool search are your levers there. And if your work is mostly long threads, Nijholt notes conversation history and tool outputs dominate the cached prefix, so trimming a few thousand schema tokens is a small slice of that thread's cost.
Before and after
Before:
- Point a converter at each REST API and get one tool per endpoint.
- Ship the whole list on every turn, with shared arguments repeated in each function and optional parameters carrying
anyOfnull branches. - Test on the frontier model you develop with, see near-perfect scores, and move on.
- Enforce "read only" with a prompt, or with argument parsing in the approval layer.
- Find out about a name collision when one integration quietly shadows another.
After:
- Group each service's verbs under a required
actionenum, then split that into read and write functions, with more write tiers for big APIs. - Emit plain types for optional parameters that default to
None, and explain shared helper arguments once in the system prompt. - Prefix every integration function with its toolkit name.
- Give a read-only agent only the read functions.
- Benchmark schema shapes on the weakest model you'd ship, and keep the shape where accuracy holds and tokens drop.
- Lock the rules in CI. MindRoom fails a pull request that adds a duplicate function name, an unprefixed integration function or a mutating default action, and keeps a short Tool Design Rules section in
AGENTS.md.
Try it
Pick one toolkit you own that has grown endpoint-shaped, such as an email or ticketing integration with eight or more functions, and run this.
- Measure the baseline. Serialize the toolkit's schemas as compact JSON and count tokens. Nijholt used
tiktokenwith theo200k_baseencoding; Jahanzaib Ahmed's measurement post used the same encoding and notes it is OpenAI's tokenizer, so Claude counts will differ. Write the number down. - Write five to ten tasks. Make each one unambiguous with one correct call, the way Nijholt's GitHub benchmark used 20 unambiguous tasks. Include at least one task that needs an optional argument and one that is a write.
- Run them on your weakest model. Use the smallest model you'd actually ship, not your daily frontier model. Record exact first-try passes and prompt tokens.
- Regroup. Merge the functions into
<toolkit>_readand<toolkit>_write, each with a requiredactionenum and no default action. Emit plain types for optional parameters that default toNone. If the write function now mixes harmless and destructive actions, split it by risk tier. - Rerun and compare. It worked if schema tokens dropped, passes held or improved, and a read-only configuration lists only the read function. If passes fell, read the failures for the two bugs Nijholt found: arguments belonging to a different action, and dropped arguments that were required before the merge. Either one means you merged too far; split again.
To keep the rules from eroding, here is our example of lines for your agent's AGENTS.md or CLAUDE.md, adapted from the rules Nijholt says MindRoom enforces:
- Every integration function is named
<toolkit>_<verb>; no two functions share a name. - Group a service's operations under a required
actionenum; never giveactiona default, and never default to a write. - Keep reads and writes in separate functions; put destructive writes in their own function.
- Optional parameters that default to
Noneuse the plain JSON type, unlessnullhas its own meaning. - Don't put negative warnings ("never controls X") in tool descriptions; tool search matches keywords.
The last line comes from a catalog trap Nijholt hit: a chat_ui entry saying it "never controls the user's browser" kept ranking next to the browser tool in keyword search until the clause was deleted.
Where it breaks
- One author, his own numbers. Every MindRoom figure above, from the toolkit and schema counts to the benchmark and caching numbers, comes from Nijholt's post and his own benchmarks on his own harness. He says the measurement scripts, the GitHub benchmark and all 400 trials are on GitHub next to the post's source; an independent rerun on another harness is the result to look for.
- Accuracy was sampled, not catalog-wide. Nijholt says he measured tokens across all 155 toolkits but accuracy only on GitHub (400 trials), the search and web consolidation (128) and the
anyOfchange (80). The 128-trial search and web test went from 58/64 to 64/64 passes with 23% fewer prompt tokens; how other integrations behave after the same treatment is untested in the post. - The 57% prefix drop isn't all tool design. Nijholt reports the fixed per-turn prefix of MindRoom's representative agent fixture fell 57%, but that drop also includes a separate system-prompt trim made earlier the same week, per the post.
- Consolidation has a floor. Below five GitHub functions, the benchmark lost accuracy: 83% at two functions and 79% at one, with no split in between tested. Wrong-operation calls doubled from four in each of the 39- and five-function arms to eight in the two-function arm. Fewer tools is only cheaper until the merged schema starts lying about what's required.
- Owning the tools is maintenance. Nijholt writes that when Slack or Gmail changes an endpoint, nobody upstream patches it for him. Renames can also open holes: an approval rule on an old write function could let the renamed one run unapproved, so MindRoom carries a fail-closed rename table that rejects retired names at startup.
- Caching softens, but doesn't erase, the win. In his week of usage, the median request was nearly 100k tokens, so in long coding threads schema savings are a small percentage of each thread's cost.
- The code-execution route has its own unknowns. Ahmed found Cloudflare's single code tool came out 4% to 53% larger than native definitions on four small servers, and he notes he counted once, on one machine, with an OpenAI tokenizer, didn't test accuracy, and found no benchmark showing agents finish more tasks with Code Mode. Anthropic's own numbers for its version, as SayBackend reports them, show it costing more on short call chains.
Nijholt also says he chose five GitHub functions from parameter overlap and approval risk tiers rather than sweeping four against five against six, so the best split for an API of a different size remains a number each builder has to measure.
Sources
- Designing functions for AI isn't the same as designing them for humans 馃敡 | Bas Nijholt 路 Bas Nijholt
- Writing effective tools for agents 路 P99Log
- Code Mode Explained: Why AI Agents Write Code Instead of Tool Calls 路 SayBackend
- Cloudflare Code Mode for MCP: How It Works, GitHub, Limits 路 Jahanzaib Ahmed
- GitHub - cloudflare/mcp: MCP server for the Cloudflare API 路 GitHub