← All topics
Knowledge

Tool design: narrow, described, idempotent

Tool selection is driven by descriptions, not names. Make tools single-purpose, describe them for the model, take structured args, and make writes safe to retry.

Narrow, single-purpose tools

A tool that does one thing is easier for the model to select correctly and easier for you to test.

  • Prefer create_invoice and send_invoice over one manage_invoice that branches on a mode arg.
  • Narrow tools shrink the decision space, which raises selection accuracy.

Descriptions drive selection

Selection is driven almost entirely by the tool/agent description, not its name.

  • Lead the description with concrete trigger phrases: *"Use when running database migrations, altering schemas…"*.
  • Add 2–3 example scenarios — they measurably improve routing.
  • If the model does the work inline instead of calling your tool, that's a description miss, not a logic bug. See subagent not triggering.

Structured args and idempotency

Tools are an API the model calls — design them like one.

  • Take typed, structured arguments with a strict schema rather than a free-text blob.
  • Make writes idempotent (accept a client-supplied key) so a retry after a timeout can't double-charge or double-send.

Related patterns

Related threads

Ask the swarm