Skip to content
mentoor

Topic 2 of 5 · 5 min read

Guiding tool choice in the system prompt

Goal: Add tool-use guidance to a system prompt that fixes a described pattern of wrong or missing tool calls.

Tool descriptions say what a tool does; the system prompt says when to prefer it, in what order, and what is off limits. An agent that has the right tools but no guidance still picks the wrong one, guesses instead of looking, or acts when it should have read.

Check yourself · 1 of 3

An agent has two search tools with similar descriptions and picks between them at random. What helps most?

Choose one answer

Why it matters

The model sees each tool's name and description and chooses on that alone. Two tools with overlapping descriptions (search_docs and search_kb) get picked at random. A tool the model does not realise it needs (a file reader) gets skipped, and the agent answers from memory. Anthropic's writing on tools for agents notes that clear, distinct descriptions and a small set of tools reduce this confusion. The system prompt is the place for the cross-tool rules no single description can carry.

What to put in the prompt

  1. A preference order. "Use search_orders before run_sql. Use run_sql only for questions the search tool cannot answer."
  2. Look before you act. "Read a file before editing it. Check the order's current status before cancelling it." Agents often edit from a stale picture of the world.
  3. Parallel calls where safe. "When you need several independent facts, call the tools in the same turn." Say what must stay sequential: a write that depends on a read.
  4. Never-allowed actions, with the reason. "Never run DROP, DELETE without a WHERE, or deploy commands. The agent has no rollback." Back this with permissions in the tool layer too; a prompt is guidance, not a lock.
  5. What to do when a tool fails. "If a call errors twice with the same message, stop and report it; do not try a different tool to get around it."

Before and after

An agent fixes a bug by reading only the file named in the ticket, then edits and reports success. The tests fail because the real cause was in a helper.

Before:

You are a coding agent. Fix the bug described in the ticket.

After:

You are a coding agent. Fix the bug described in the ticket.
Before editing, search the repository for every caller of the function you
plan to change and read them. Read independent files in parallel.
After editing, run the project's tests with the `run_tests` tool and read
the output. Never edit a test file to make a run pass.

What goes wrong

  • Guidance that repeats the tool description. It costs tokens and adds nothing. Put only what is not obvious from the description.
  • Promising tools the agent does not have. "Use the browser tool" when none is attached leads to made-up tool calls.
  • Relying on the prompt as the only guard. A destructive tool still needs a permission check or a confirmation step in code; models drop instructions.

Examples

Two overlapping search tools

An agent has search_docs (product manuals) and search_tickets (past support cases) and keeps using the first for everything. Add one sentence: "For how a customer's issue was solved before, use search_tickets. Use search_docs for how a feature is supposed to work." The prompt now says when each applies, which the descriptions alone did not.

A guard that lives in code

The prompt says "never delete customer records". The delete tool is also registered with a required confirmed_by field that only the app can fill. If the model ignores the prompt on a bad turn, the call still fails. Prompt for intent, code for limits.

Key points

  • The system prompt carries cross-tool rules: preference order, look-before-act, parallel calls and what is forbidden.
  • Tell the agent to read the current state before it changes anything.
  • Say which calls may run in parallel and which depend on an earlier result.
  • Give each forbidden action a reason, and enforce it in the tool layer as well.
  • Tell the agent what to do when a tool fails so it stops instead of working around the error.

Common mistakes

  • Writing tool guidance that restates each description instead of the rules that cross tools.
  • Leaving out "read first", so the agent edits or cancels based on what it assumes.
  • Forbidding a dangerous action in the prompt only, with no check in the tool itself.
  • Never saying what to do on a tool error, so the agent retries blindly or switches to a riskier tool.

Check yourself · 2 of 3

Why tell an agent to "read the file before editing it"?

Choose one answer

Check yourself · 3 of 3

A system prompt says "never run destructive SQL", and the agent has a run_sql tool with full database rights. What is the best next step?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic