CHAPTER 03 · Tool Design · 8 / 11
Tool results are also an interface
The result you return is read by the model, so design it too:
- Return useful errors, not exceptions. If a tool can't do the thing, return a message the model can act on: "No edits applied; refine your context anchors and retry." The model will adapt. A thrown exception just crashes the turn.
- Reinforce instructions at the point of use. Returning a document? Prepend a short reminder of how to cite it. Instructions delivered alongside the data are obeyed more reliably than ones only in the system prompt.
- Distill, don't dump. If a tool calls an external API with a huge response, return the decision-relevant fields and cap long ones, rather than flooding the context. Leave a separate tool for "get more detail" when needed. (See Chapters 5 and 7.)
- Keep results stable and parseable if your code will read them too.