Use typed boundaries for application capabilities.
1. Tool schema
Expose narrow Kotlin operations with clear parameter descriptions. Generated tool bindings reduce boilerplate but do not replace validation of values supplied by a model.
2. Domain checks
Look up the current identity outside model arguments. Enforce record ownership and supported operations in the service layer. Return bounded results instead of full database objects.
3. Failure contracts
Differentiate not found, invalid input, forbidden and temporary failure. A useful failure lets the agent recover without inventing a successful result.
Worked scenario
A ticket lookup receives an ID owned by another customer. The tool returns a permitted error category and never leaks the ticket title.
Apply it
Implement a fake ticket lookup with success, missing and forbidden cases. Test forged identifiers.
Check your understanding
Tool safety is enforced even if the model ignores its instructions. Explain the decision and show evidence from your implementation or design. If you cannot demonstrate it yet, revisit the relevant section before continuing.