Skip to main content
An agent with many tools can spend a planning step, or a call, on the wrong one. This example reads a request and says which of your tools fits it, or that none does. Use it before your agent plans a call, so you can give the planner only the tool that fits.

How it works

The context is JSON with the user’s request. The keys are yours to choose. One single decision, tool, has one outcome per tool, named after it. Each outcome’s description is the tool’s own description, which is how the model learns what each tool does. A none outcome covers requests no tool can do. One decision can list up to 255 outcomes, none included. Its policy has abstain_below at 0.5: if no outcome reaches a probability of 0.5, the action is abstain.

Try it

Open this recipe in the playground to run it without an account. The request there is a table for four at Dishoom King’s Cross this Friday at 7pm, under Priya. The tools are search, book, directions and send a message. To run it from your code, set SQWISH_API_KEY as in the quickstart, then send this request:

Act on the answer

Picking a tool doesn’t check its arguments, such as the date, the party size or the name your agent will pass. Nor does it check whether the call is allowed. Check the call before it runs.

Adapt it to your data

  • Your tools. Add one outcome per tool, with the tool’s name as the outcome and its description as the outcome’s description. Say what each tool does and where it ends, as you would for a person. The descriptions are all the model knows about your tools.
  • Keep none. Without it, the model has to name a tool even when none fits.
  • Earlier turns. If the request refers back to the conversation, send that under its own key, such as conversation, next to request.
  • Many requests. Send one request per user request.

What to watch

  • Requests that need two tools, such as “find a place and book it”. The decision picks one.
  • Tools whose descriptions overlap. Rewrite them so each one says where it ends.
  • Requests no tool fits. In testing, it often named a tool for these. If a wrong call is costly, check probabilities.none against a threshold of your own, tested on your own requests.

How well it works

Measured with kettei-core on 1,000 examples from a public dataset, it chose the right answer 78.9% of the time. Always picking the most common answer scores 41.4%. Your own data will differ, so measure it on examples of yours before you rely on it (improve a decision).
Always picking the most common answer has an accuracy of 0.414, and guessing by how common each answer is has a log loss of 2.9656.These are past results on one dataset, not a promise of accuracy on yours.

Next steps