OpenAI tool loop
Define tools in the Chat Completions format:finish_reason is tool_calls. Preserve the
assistant message and return one tool message for every requested call.
Anthropic tool loop
Anthropic usestool_use and tool_result content blocks:
Production rules
- Treat model-generated arguments as untrusted input.
- Validate arguments against the tool schema before execution.
- Apply authentication and authorization in the tool implementation.
- Set timeouts and output-size limits.
- Require confirmation before destructive or high-impact actions.
- Return concise, structured errors so the model can recover.
- Execute calls in parallel only when they are independent.
function. Responses uses top-level name, description, and
parameters fields on each function tool. Anthropic uses input_schema on
/v1/messages.
Responses also accepts free-form custom tools with type: "custom". Custom
calls use custom_tool_call and custom_tool_call_output items instead of the
function-call item types. Namespace tools group function or custom tools under
type: "namespace"; namespaced function calls include a namespace field that
must be preserved in later requests.
For complete Responses function and custom tool loops, see the
Responses API reference.