cd /news/ai-agents/designing-functions-for-ai-isn-t-the… · home › topics › ai-agents › article
[ARTICLE · art-177873] src=nijho.lt ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Designing functions for AI isn't the same as designing them for humans 🔧

MindRoom developer and blogger nijho.lt redesigned all 155 built-in toolkits after deleting the Agno AI framework underneath, cutting 729 default functions to 298 and shrinking total tool schemas by 50%, while the fixed per-turn prefix of MindRoom's representative agent fixture dropped 57%. The redesign consolidates per-endpoint functions into action-parameterized tools, such as a single email(action, to, message_id, subject, ...) call replacing separate read_email, write_email, save_draft, star_email and archive_email functions that each repeated shared arguments on every turn. The author argues that converting a REST API one-tool-per-endpoint into an MCP server is the least token-efficient way to give an AI tools, and that dedicated tool schemas still matter for permissions and authentication even when a shell tool suffices for pure coding tasks.

recommendation

Design agent tools for the model, not as REST wrappers: merge related endpoints into one action-parameterized tool so shared arguments appear once, which cut MindRoom's schemas 50% and its per-turn prefix 57%.

more in playbook: Designing agent systems
read17 min views4 publishedNov 28, 2026

A lot of people connect AI agents to their services by converting an existing REST API straight into an MCP server, one tool per endpoint. That’s probably the least token-efficient way to give an AI tools. Designing functions for an AI isn’t the same as designing them for a human programmer.

I learned how much difference that makes this week while redesigning all 155 built-in toolkits in MindRoom (GitHub , docs), after deleting the AI framework underneath it. Across the whole catalog, I cut 729 default functions down to 298 and shrank total tool schemas by 50%. The redesigned tools support more options, and the fixed per-turn prefix of MindRoom’s representative agent fixture dropped by 57%.

For a lot of people, AI harnesses feel like magic. Really, all the magic is in the models. Every request an agent sends to an AI API is mostly freeform natural language text, plus a block of structured data. That structured data is a list of tool schemas describing every tool the model is allowed to call, from basics like reading a file (read_file(path)) or running a shell command ( bash(command)) to integrations like GitHub or email. When the model wants to use one, it replies with the tool name and arguments (for example bash with ls data/), and the harness runs the code on your own machine and sends the result back. Any AI harness is just that loop: hand the model a prompt and tool schemas, run the tools it asks for, and repeat.

Because those schemas travel along with the conversation on every turn, their shape has a direct cost.

If you define tools the way you’d write normal Python functions or wrap a REST API into MCP, you end up very verbose.
For email alone, you might expose separate functions like `read_email`, `write_email`, `save_draft`, `star_email`, and `archive_email`.

Every one of those functions repeats shared arguments like to, message_id, or subject, burning tokens on every turn. Instead, you can describe the same capability as one email(action, to, message_id, subject, ...) tool where action is read, write, draft, star, or archive, and pay for the shared arguments once.

A common reaction here is that once you give an agent a shell tool, you have all the harness you really need. For pure coding tasks, that’s often true, and in my tests on native harness tools a single-shell minimal agent used far fewer tokens than a full toolset. It stops being enough as soon as you care about permissions and authentication.

Once you hand an agent a shell, it’s very hard to say “you can read my email, but you need my approval before sending an email.” You can try to enforce that with narrow API scopes, which gets messy fast across dozens of services. Authentication is also painful from a shell: you can share a raw API token with your AI, though that’s not as nice (or as safe) as signing in once with SSO and letting the harness hold the credentials while gating individual tools. That’s why dedicated tool schemas still matter, and why their design matters.

When I started building MindRoom nearly a year and a half ago, I picked Agno mostly for its built-in library of 87 integrations like GitHub, Gmail, Slack, and Docker. By late October I’d already replaced Agno’s runtime after adding 126 workarounds (which I wrote about in Roll your own, fork the rest), and this week I deleted the rest of it in about 21 hours using my parallel orchestrator setup.1

With today’s models, writing thin API wrappers yourself is straightforward because popular APIs show up all over the training data. Owning all 155 toolkits also meant I was no longer stuck with Agno’s one-function-per-endpoint layout. In those same native-harness tests, frontier models didn’t care much whether tool names matched what they were trained on, while fixed per-request tokens mattered a lot. Once MindRoom owned the files, I could redesign the whole catalog around that lesson.

Before the rewrite, MindRoom’s toolkits looked just like auto-converted REST APIs, with services like GitHub, Gmail, and Docker exposing twenty to forty separate functions each. Grouping related verbs under an action= parameter cut default functions across all 155 toolkits from 729 down to 298 and halved total schema size, keeping operations like all 39 GitHub actions intact.<sup>2</sup> Often the consolidated tools ended up with cleaner parameters and more consistent validation than the wrappers they replaced.

At first I considered collapsing every toolkit into a single mega-tool, which turned out to be a bad idea.

Permissions and [human approvals](https://docs.mindroom.chat/tool-approval/) live at the function boundary.
If you want a read-only agent, you don’t want to rely on faith and a prompt asking it not to write.

You want to enforce it in code by never giving it the write function in the first place. When reads and writes share one action= tool, a read-only agent still sees every write argument in its schema. Your approval layer also has to parse arguments on every call just to tell a lookup from a delete.

So I went the other direction on four built-in mega-tools (triggers, desktop, browser, and matrix_api) and split them into separate read and write functions, while bringing workflow down to the same read/write pair.<sup>3</sup> Splitting them did add some schema overhead per split, because shared arguments now appear on both functions, yet after the rest of the cleanup every one of those five toolkits still finished smaller than it started.

For large APIs, one read/write pair isn’t enough. MindRoom’s GitHub toolkit covers 39 actions across dozens of parameters, so collapsing it into two functions would still leave a huge write tool mixing issue comments with repository deletes. I split it into five functions instead: two reads (repos and files vs issues and pull requests) and three write tiers (issues, pull requests, and repo mutations), keeping each schema small and separating safe writes from destructive ones.4

Fewer functions was only part of the savings. Looking across all 155 toolkits at once turned up two other sources of extra tokens that hit almost any Python agent harness.

First, when you annotate a parameter as limit: int | None = None in Python, standard JSON-schema generators emit {"anyOf": [{"type": "integer"}, {"type": "null"}]} instead of "type": "integer". That extra null branch is almost always redundant: the parameter is already absent from JSON Schema’s required list, so omitting the key passes None in Python anyway. I changed the schema generator to emit plain JSON types for optional parameters defaulting to None, while still accepting an explicit null at runtime if a model sends one.<sup>5</sup> In that single commit, anyOf blocks across the catalog dropped by 71%, and a five-model A/B check on optional-heavy tool calls scored 40/40 both before and after. Parameters where null carries real meaning stay untouched, like a SQL limit: int | None = 10 where passing null means “return all rows”.

Second, MindRoom adds two optional helper arguments to tools: background_after to push slow work into a background job, and mindroom_output_path to write large outputs to disk. Repeating their full descriptions on every function burned nearly a hundred tokens per tool. Explaining both once in the system prompt and letting fast local tools opt out cut that overhead by almost three quarters.6

Here’s how all three changes shrink all 39 functions of the GitHub toolkit step by step, drawn to token scale (click any step to and inspect it).

Earlier that same week, before the toolkit rewrite started, I also tightened MindRoom’s default system prompt to drop stale instructions and hide sections an agent doesn’t use.<sup>7</sup> Combined with the tool rewrite, the fixed per-turn prefix of MindRoom’s representative Claude agent fixture (identical config and conversation history) dropped by more than half, and its tool list shrank from 23 functions down to 9. Even the calculator in that fixture went from eight functions (add, subtract, multiply, divide, exponentiate, factorial, is_prime, square_root) to one ( calculate).

Frontier models like Claude Opus 5.5 and GPT-6.2 Astra get almost any tool call right, no matter how clunky or bloated the schema is. If all your tests score 10/10 or 20/20, you have no signal.

To evaluate tool schemas properly, you have to pick the dumbest model you can still reasonably do useful work with, and see where it starts failing. For me, that means self-hosted models that run on typical consumer hardware. Lately I’ve been experimenting a lot with Inkling 2 Mini, which has been great, and before that Qwen 3.8 27B was my go-to local model.

To see where consolidation stops helping and starts hurting, I ran a controlled 400-trial benchmark on MindRoom’s GitHub toolkit: the same 20 GitHub tasks across four consumer-scale open-weight models (local inkling-2:mini plus qwen3.5-9b, gemma-4-26b, and gemma-4-31b via OpenRouter) and gpt-5-mini as a stronger hosted reference, tested against four schema shapes covering the exact same 39 operations.8

The five read/write functions tied the 39-function REST schema on exact first-try accuracy (93/100 each) while using a third of the prompt tokens and staying within two tasks either way on every model. Pushing further down to two functions or one mega-tool barely saved another couple hundred tokens, and dropped average accuracy to 83% and 79%.

Wrong-operation calls doubled from four in each of the 39-function and five-function arms to eight in the two-function arm. The failure logs also showed two structural schema bugs. First, the parameter list grows to the union of every action (42 parameters in the single-tool arm), so smaller models start passing wrong-action arguments like branch instead of ref or issue_number instead of number. Second, JSON Schema’s required list shrinks to the intersection of every action: the moment create_repository shares a tool with edit_pull_request_comment, you can’t mark repo_name as required anymore, and models start dropping it. Meanwhile, gpt-5-mini, the strongest model in the set, stayed at 95 to 100% across all four shapes, so if I’d only tested on it, I’d have missed the 14-point average drop.

In a separate 128-trial live A/B, I tested the search and web consolidation, which grouped operations under an action parameter in eleven toolkits.

Four smaller models went from 58/64 to 64/64 passes while using 23% fewer prompt tokens.9 Alongside those benchmarks, I added a small 12-task evaluation harness (evals/tool_calling/) that boots a real MindRoom agent with inline tools plus deferred tools (docs) and runs full multi-turn loops on smaller models.<sup>10</sup> Running that harness alongside a catalog-wide audit turned up three more mistakes.

Negative warnings confuse tool search. The chat_ui catalog entry said “never controls the user’s browser” to stop models from confusing it with the browser tool. Because tool_search matches keywords, searching for "browser" kept ranking chat_ui right next to browser.

Deleting that negative clause fixed retrieval. Never default an action to a write. matrix_message defaulted action to "send". Whenever a model forgot to pass action, it defaulted to posting a message. Making action required prevented accidental sends.11

Silent name collisions across toolkits. At the start of the week, 47 function names collided across the catalog, including search_web, run_sql_query, send_email, and crawl. Enabling two integrations silently shadowed one of them.

Consolidating the catalog and prefixing integration functions as <toolkit>_<verb> took collisions from 47 to zero.12 All of those rules now live in automated CI tests and a short Tool Design Rules section in AGENTS.md.<sup>13</sup> A pull request can’t merge if it adds a duplicate function name, an unprefixed integration function, or a mutating default action.

A common pushback against optimizing tool schemas is that prompt caching discounts input tokens by 90% or more, so fixed schema tokens barely affect your bill. I checked my own MindRoom usage over the past seven days across 345,924 requests to see if that’s true.14

Across all models combined, 91.8% of all tokens were cache reads, and yet input and cache tokens still accounted for 81% of total spend while output was only 19%. Those “cheap” cache reads alone added up to 25% to 40% of the bill across models, and 74% to 87% once you include cache writes for GPT-6.2 Sol, GPT-6.2 Astra, and Claude Opus 5.5. And that’s in a harness that goes to great lengths to keep the prompt cache warm: MindRoom holds the system prompt prefix fixed even when the prompt or memory changes (injecting only a diff later in the thread), and reuses the warm cached prefix during compaction, which many open-source harnesses don’t do.

That doesn’t mean smaller schemas will cut your whole bill in half. In long coding threads (my median request size over that week was nearly 100k tokens), conversation history and tool outputs make up most of that cached prefix, so trimming a few thousand schema tokens is a small slice of the total. It matters far more on short-to-medium loops, fresh subagents, cold cache writes, and local models where every extra thousand tokens slows down prefill directly.

When Slack, Gmail, or Spotify changes an endpoint, nobody upstream is going to patch it for me. Most of Agno’s 87 toolkits were thin REST wrappers around httpx, and MindRoom still uses official vendor SDKs where the protocol is complex, so I think the trade is worth it. It’s still more code to maintain.

Merging and renaming 729 functions down to 298 can also break existing configs without warning. If someone has an approval rule on an old write function like slack_post, upgrading could let the renamed slack_send run unapproved. So MindRoom carries a fail-closed rename table that rejects retired tool names in approval configs at startup and prints the replacement name.<sup>12</sup> That migration layer is extra code I wouldn’t need if I’d never changed the names.

More broadly, I worry a lot less about breaking config compatibility than I used to, because I don’t expect a human to do the upgrade by hand anyway. An agent runs the upgrade, and because MindRoom ships with mindroom config validate and mindroom doctor (CLI docs), the error messages point straight at the fix and the user probably never even notices.

And I measured tokens across all 155 toolkits, not live accuracy across all 155. I tested accuracy on GitHub (400 trials), the search and web consolidation (128 trials), and the anyOf change (80 trials), not every integration in the catalog.

Wrapping a human API straight into tools is quick at first, but you pay for it in tokens on every turn. Designing tools for models instead of humans halved MindRoom’s schema size and separated read and write permissions. In the cases I tested, the redesign kept them just as reliable for small models at a fraction of the tokens.

The catalog measurement scripts and results, the GitHub benchmark script, tasks, and all 400 trials, and the aggregate 7-day spend breakdown are on GitHub next to this post’s source.

At commit a0471bd2d (2026-11-25 14:27 PST), src/ still had 233 Agno imports across 106 files (87 toolkit modules) and 47 AGNO_COMPAT: markers across 30 files (down from 126 reported on Oct 19). All dropped to 0 across nine waves in mindroom-ai/mindroom: Wave 1 #4378 (merged 2026-11-25 22:30 PST), Wave 2 #4389, Wave 3 #4390 and #4408, Wave 4 #4388, Wave 5 #4394, Wave 6 #4401, Wave 7 #4392, Wave 8 #4403, and Wave 9 #4419 (merged 2026-11-26 19:42 PST). ↩︎

Measured from tests/fixtures/agno_parity/tools/schemas.json as compact JSON tokenized with tiktoken o200k_base at commits df7f97a04 (2026-11-24 13:16 PST) vs 295a31a16 (2026-11-27 17:34 PST): github 6,670 to 1,658 tokens (-75.1%), gmail 4,180 to 1,266 (-69.7%), docker 3,129 to 819 (-73.8%), and the nine Microsoft 365 toolkits (outlook_mail, outlook_calendar, microsoft_files, microsoft_teams, microsoft_sharepoint, microsoft_todo, microsoft_onenote, microsoft_meetings, microsoft_people, PR #4435) from 17,408 to 7,168 tokens (-58.8%). With optional default-off functions enabled (schemas_all_enabled.json), the 155 toolkits total 317 functions with 0 duplicate names. ↩︎

The split PR #4458 increased the compact JSON token count of each toolkit’s functions array from 1943198dd~1 to 1943198dd. Over the full Nov 24 to 27 comparison (df7f97a04 to 295a31a16), which also includes cleanup PR #4471, all five finished smaller: triggers 1 to 2 functions (-6.3% tokens), desktop 1 to 3 (desktop_read, desktop_control, run_desktop_shell, -6.7%), browser 1 to 2 (-13.2%), matrix_api 1 to 2 (-7.8%), and workflow 6 to 2 (-41.1%, consolidated to 1 in PR #4436 then split to read/write in #4458). ↩︎

On main, the 39 GitHub actions span 43 unique parameters (20 across reads, 29 across writes). The five functions in src/mindroom/custom_tools/github.py are github_read_repo (11 actions, 13 parameters), github_read_issues_prs (10 actions, 16 parameters), github_write_issues (7 actions, 8 parameters), github_write_pr (4 actions, 16 parameters), and github_write_repo (7 actions, 14 parameters, including delete_repository and delete_file). I chose five from parameter overlap and approval risk tiers rather than sweeping 4 vs 5 vs 6, then benchmarked 39 vs 5 vs 2 vs 1 functions below. ↩︎

PR #4432 (154614019), measured directly against parent 154614019~1 on schemas.json (315 functions in both): anyOf dropped from 1,037 to 298 (-71.3%) and tokens from 77,143 to 70,439 (-8.7%). Plain JSON types are emitted only for derived two-member nullable unions defaulting to None (tool_schema.py), and OpenAI Responses serialization sets strict: false automatically when optional fields are present (responses_wire.py) so omitted arguments aren’t rejected. A live 5-model A/B eval on 8 optional-heavy tool cases (80 trials across gemma-4-26b-a4b-it, gemma-4-31b-it, qwen3.5-9b, gpt-5-mini, and local inkling-2:mini) scored 40/40 in both arms (100% accuracy parity) while cutting prompt tokens by 5% to 19%. ↩︎

PR [#4424](https://github.com/mindroom-ai/mindroom/pull/4424) (`0ca55779b`).
Hiding `mindroom_output_path` from a fast tool’s schema still keeps automatic >50 KiB output-to-file protection active at runtime. [↩︎](#fnref:6)

PR [#4332](https://github.com/mindroom-ai/mindroom/pull/4332) (`00fd8ff3a`, merged 2026-11-24 13:41 PST) and PR [#4345](https://github.com/mindroom-ai/mindroom/pull/4345).

Fixture measured on tests/fixtures/agno_parity/prompts/agent_anthropic.json (requests[0]) at df7f97a04 vs 295a31a16 (o200k_base). ↩︎

Controlled single-turn benchmark (20 unambiguous GitHub tasks spanning all five groups, 4 arms, 5 models, 400 trials total, temperature 0 where supported, harness meta-parameter stripped from all arms so pure API shape is compared). I mechanically merged the five-function arm into the two- and one-function arms by concatenating the descriptions and setting required: ["action"]. Schema sizes (o200k_base): 39 functions 4,480 tokens (max 10 params/fn), 5 functions 1,488 tokens (max 15), 2 functions 1,338 tokens (max 28), 1 function 1,258 tokens (max 42). Exact first-try pass rates (out of 20) for 39 / 5 / 2 / 1 functions: inkling-2:mini 16 / 17 / 13 / 13, qwen/qwen3.5-9b 20 / 18 / 16 / 14, google/gemma-4-26b-a4b-it 19 / 18 / 15 / 14, google/gemma-4-31b-it 18 / 20 / 20 / 18, openai/gpt-5-mini 20 / 20 / 19 / 20. Totals across 100 trials per arm: 93 / 93 / 83 / 79 passed. Wrong-operation errors: 4 / 4 / 8 / 5. Wrong or leaked parameter errors: 0 / 0 / 1 / 7.

Missing-argument errors: 3 / 3 / 8 / 9. ↩︎ PR #4439 (c4ea7f762) consolidated 11 search, research, math, and web-scraping toolkits (including calculator 8 to 1, serper 4 to 2, exa 5 to 2, brightdata 4 to 1, oxylabs 4 to 1, spider 3 to 1). Live A/B eval across 16 cases and four models (64 trials per arm, 128 trials total): gemma-4-26b-a4b-it 14/16 to 16/16 (-19.1% prompt tokens), gemma-4-31b-it 14/16 to 16/16 (-30.6%), qwen3.5-9b 16/16 to 16/16 (-23.0%), gpt-5-mini 14/16 to 16/16 (-19.8%).

Overall passes went from 58/64 to 64/64, with 23.4% fewer prompt tokens. ↩︎ PR #4440 (d6c321073) added evals/tool_calling/. ↩︎

PR #4477 (dad71b234, merged 2026-11-27 17:18 PST) removed the action="send" default on matrix_message and enforced required action= enums across the catalog in CI (test_catalog_action_enums_are_required, with one read-only exception for matrix_room). ↩︎

Consolidation reduced duplicate function names from 47 to 12. PR #4464 (0dbaeb16e) took collisions from 12 to zero by normalizing 74 functions across 42 integration toolkits and added fail-closed approval rename mappings in src/mindroom/config/retired_tool_renames.py. ↩︎ ↩︎

tests/tool_system/test_toolkits.py and AGENTS.md Tool Design Rules (PRs #4464, #4473, and #4477). ↩︎

Measured across 345,924 OpenRouter-priced MindRoom requests over seven days (Nov 20 to 27, 2026) using published OpenRouter list prices for prompt, completion, input_cache_read, and input_cache_write tokens. Token totals: 91.8% cache read, 5.9% uncached input, 1.8% cache write, and 0.6% output. The median request input size was 97,313 tokens (p90: 268,837). In order of cache read, cache write, uncached input, and output, spend shares across all models were 29.7% / 21.6% / 30.0% / 18.7%.

For `GPT-6.2 Sol`, the shares were 40.1% / 41.2% / 0.1% / 18.6%.
For `Claude Opus 5.5`, the shares were 38.7% / 35.7% / 2.7% / 22.9%.
For `GPT-6.2 Astra`, the shares were 33.4% / 54.0% / 0.2% / 12.5%.
For `Claude Fable 5.2`, the shares were 28.3% / 24.6% / 7.4% / 39.6%.
For `Gemini 4 Neon`, the shares were 24.8% / 0.0% / 58.1% / 17.1%. [↩︎](#fnref:14)
── more in #ai-agents 4 stories · sorted by recency
── more on @mindroom 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/designing-functions-…] indexed:0 read:17min 2026-11-28 · —