OpenResponses.ToolPolicy (OpenResponses v0.1.1)

View Source

Validates model-emitted tool calls against tool_choice and allowed_tools.

Called by the agentic loop before dispatching any function call. Returns :ok when the call is permitted, or an error that causes the loop to re-sample with an error message instead of executing the tool.

Enforcement rules

tool_choiceBehaviour
"none"All tool calls rejected
%{"type" => "function", "function" => %{"name" => n}}Only that function is allowed
"auto" / "required" / nilAllowed — subject to allowed_tools

If allowed_tools is a non-empty list, the called tool name must be in that list regardless of tool_choice.

Summary

Functions

validate(arg1, tool_choice, allowed_tools)

@spec validate(map(), term(), list() | nil) :: :ok | {:error, atom()}