Build
Tool calling
Let the model propose; let the product authorize
A tool loop crosses model, Router, orchestration and product boundaries. Each boundary has a distinct responsibility.
1. Define the tool
Use a narrow name, description and JSON Schema. Return only the fields required for the next model step.
2. Receive a tool call
Use a route whose primary and fallbacks all support tools. Preserve tool_call_id and finish_reason from streaming or non-streaming responses.
3. Validate and execute
Validate arguments, authorize against the product user, set a timeout and attach an idempotency key before any side effect.
4. Return the result
Append the tool result and request the final response through the same governed route. Reef can own this loop; Router does not execute the tool.
