A small contract for every tool an agent can call
If a tool can change data or answer a customer, its inputs, outputs, and failure states should be boring enough to test without a model.
An agent is only as trustworthy as the tools it can reach. We treat each tool like a small public function, even when the only caller is a model.
The contract we write down before the prompt:
- Input. The few fields the tool accepts. No free-form "context" blob.
- Output. A typed result that includes success and failure, not only the happy path.
- Side effect. Whether the tool reads or writes. Write tools are not available on the first pass.
- Stop condition. The result that means "do not call this again."
type LookupResult =
| { status: "found"; summary: string }
| { status: "missing" }
| { status: "unavailable"; retryable: boolean };
The prompt can mention these states. It should not be the only place they exist. A unit test that passes a missing order id, and expects status: "missing", tells us more than another demo transcript.
