Offering fewer tools up front and the rest on request

Ask @todoist to add a task and the model reads the definitions of every Todoist tool before it answers: tasks, projects, sections, labels, reminders, assignments, filters. There were 39 of them, and their definitions and instructions weighed about 55,000 characters. They were in every model request of a Comms run, whatever the question.

Runs use few of them. A run that adds a task does not need to know how to create a filter or update a reminder. It still pays for reading them, on every turn.

What the articles argue

Anthropic’s Writing effective tools for agents makes the point that a tool set is not better for being larger: “More tools don’t always lead to better outcomes.” Too many or overlapping tools distract the model, and every definition costs context. The same article asks that a tool’s errors tell the agent what to fix, instead of returning an opaque code.

Code execution with MCP takes the cost argument further. When every definition is loaded up front, the agent reads a large amount of text before it reads the request. The fix it proposes is to let the agent load definitions on demand: find a tool, then read the definition of only that tool, at the level of detail it needs.

Fewer Todoist tools in each request

With agent-core#563, a Comms run is offered 19 Todoist tools directly: the five writes that add, change, complete, reopen or reschedule a task, and the reads runs actually call. The other 20 are named in the instructions, one line each, with the first sentence of their description. Code writes that list from the tool definitions, so it can’t drift from the tools themselves. It closes the Todoist instructions (trimmed to four of the 20 tools):

More Todoist tools exist than the ones you are offered. Before you say Todoist cannot do something, look for it here. To use one, get its arguments with `todoist.describe_tools`, then run it with `todoist.run_tool` when it reads and `todoist.run_write_tool` when it changes something. They read: `todoist.find_filters`: List all personal filters or search for filters by name. `todoist.find_labels`: List personal labels and shared labels. […] They change something: `todoist.manage_assignments`: Assign, unassign or reassign up to 50 tasks at once. `todoist.add_projects`: Add one or more new projects. […]

The description of todoist.find_labels runs to five sentences, and its input schema to three fields. The list keeps the first sentence and nothing else.

Three tools reach the ones left out:

  1. todoist.describe_tools returns the description and input schema of up to 5 tools. It makes no call to Todoist.
  2. todoist.run_tool runs a tool that reads.
  3. todoist.run_write_tool runs a tool that changes something.

The two run tools take only the names left out. Each checks the arguments with that tool’s own schema, then runs the tool itself, so the result, the links and the way a sent draft’s text is bound are the same as when the tool is offered directly. A write can’t go through the read tool, and a read can’t go through the write tool.

The model reads the one-line list of tools left out, calls describe_tools to get the arguments of the tool it needs, then calls run_tool or run_write_tool, which checks the arguments against that tool's schema and runs it against Todoist.

Here is one evaluation case followed through. The asker writes in a thread of the synthetic workspace about the start-of-term feast:

Create a Todoist project called Feast planning with two sections, To do and Done.

Without the change, both tools are in front of the model, and it calls them in order:

comms.load_thread → todoist.add_projects → todoist.add_sections

With the change, neither is offered. The model calls todoist.describe_tools once. For those two names, the tool returns this (generated from the definitions, not copied from the run; trimmed):

{
  "tools": [
    {
      "name": "todoist.add_projects",
      "description": "Add one or more new projects.",
      "run_with": "todoist.run_write_tool",
      "input": {
        "type": "object",
        "properties": {
          "projects": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string", "minLength": 1, "description": "The name of the project." }
                // trimmed: parentId, isFavorite, viewStyle, description, color, workspace
              },
              "required": ["name"]
            }
          }
        },
        "required": ["projects"],
        "additionalProperties": false
      }
    },
    {
      "name": "todoist.add_sections",
      "description": "Add one or more new sections to projects.",
      "run_with": "todoist.run_write_tool",
      "input": {
        // trimmed: the same shape, an array of sections
        // whose items require "name" and "projectId"
      }
    }
  ]
}

Then two todoist.run_write_tool calls, one after the other, because a section needs the ID the project write returns.

With the change, the answer is the one a run without it gave (links removed):

I have created the project Feast planning with the sections To do and Done.

What changed is the path: four tool calls instead of three, and one more model turn.

A run anchored on a Todoist task is still offered every read directly. This is how Comms runs work in production today.

Tools that explain themselves

Asking for a tool only works if the model can recover from a wrong call.

A month earlier, agent-core#129 had started on this: before it, any tool given an invalid input answered “The tool input was invalid.” and nothing else. The model had no way to tell which field was wrong. That PR made every tool answer with the validation error itself, cut at 300 characters. From its test, a test tool whose schema refuses latest together with query:

// Before
The tool input was invalid.

// After
The tool input was invalid: ✖ A latest read takes no query.

The run tools of #563 use the same rule: an invalid input is answered with what is wrong in it, and recorded as a failed call that wrote nothing. From the tests, a project given its workspace by name (result trimmed):

// todoist.run_write_tool
{ "tool": "todoist.add_projects", "input": { "projects": [{ "name": "Team onboarding", "workspace": "Marketing" }] } }

// Result
{
  "result": "The input of todoist.add_projects is invalid: ✖ Give the workspace by its id from the workspace list, not its name.\n  → at projects[0].workspace\ntodoist.describe_tools gives its arguments.",
  "failure": "invalid_args",
  "write": "none"
}

The refusal names the field, says what to send instead, and points back to the tool that gives the arguments. Nothing reached Todoist.

The tools of connected services had the same problem one level down. When @todoist runs an action of a service the asker connected (Gmail, for example), it picks arguments from a list that gives field names only. When Automations refused them, the refusal held one validation error. With agent-core#557, that refusal now carries the action’s input schema. From its test, a Gmail read called with id where the action wants messageId:

// automations.run_connector_action
{ "connector_id": "gmail", "action": "get-message", "args": { "id": "abc" } }

// Before (the same refusal without the schema)
{ "unavailable": "Arguments rejected for get-message: (root) must have required property 'messageId'.", "code": "invalid_args" }

// After (trimmed)
{
  "unavailable": "Arguments rejected for get-message: (root) must have required property 'messageId'.",
  "code": "invalid_args",
  "input_schema": {
    "type": "object",
    "properties": { "messageId": { "type": "string" }, "format": { "enum": ["full", "metadata"] } },
    "required": ["messageId"]
  }
}

Before, the model learned that messageId was missing, but not its type or what else the action takes. It had to guess again or spend a call listing the action.

The model gets the definition exactly when it needs it, which is the on-demand idea applied to errors. A write is not sent again, and the schema is only added when it fits in the result.

The last piece is about not offering what will fail. @todoist lists what a connected service can do before it acts. That list showed every write that is not destructive, but Automations lets a delegated client such as Agent Core run only some of them. The model was offered writes that were then refused. With agent-core#561, Automations marks each action it allows a delegated client to write, and the list keeps only those. The model is no longer offered a write that Automations will refuse.

What we measured

Static measurement first. The Todoist part of each model request went from about 55,000 to about 34,000 characters, 38% less.

Then the live model, on the evaluation set (a synthetic workspace, with the judge off). We added three cases and played each three times:

Case Tools called Result
Create a project with two sections describe_tools, run_write_tool twice Passes 3 of 3
List my labels describe_tools, run_tool Passes 3 of 3
Add a task add_tasks, no lookup Passes 3 of 3

The project case cost about 8% more tokens with the change than without (54,000 against 50,000), for the extra turn. Then the whole evaluation set, played once with the change: all 127 runs passed their checks, and the model asked for a tool only in the two cases that need one.

What we did not measure: no evaluation case plays a refused connector argument, so #557 is not measured with the live model. And the evaluation run with the change was not played at the same time as the one without it, so it can’t tell whether the extra turn adds latency in practice.

What I’d tell someone doing the same

  1. Pick the direct list from usage, not from intuition. We offered directly the tools runs called, and the writes on a task itself. Every reached tool is recorded with its name, so a tool asked for often can move to the direct list.
  2. Generate the list of what is left out from the definitions. A hand-written list goes stale the first time a tool changes.
  3. The trade-off is one turn. A run that needs a tool left out makes one more model request. On the case we measured that cost 8% more tokens. A Comms run that isn’t anchored on a task and needs nothing from the tools left out reads 38% less Todoist text in each model request. A run anchored on a task still gets every read directly.
  4. Keep the checks where they were. Discovery should change what the model reads, not what it is allowed to do.
  5. Make errors carry the fix. A model that asks for a tool will sometimes call it wrong. A refusal that names the problem, or carries the schema, turns a dead end into a second try.
  6. Don’t offer what will be refused. Hiding a tool the model can’t use is cheaper than explaining the refusal after the call.

A new tool the package adds is left out of the direct list until someone adds it. That is deliberate: a tool reaches runs directly only once we decided it should.