Class ToolCallPolicy
Per-turn policy that governs if and how the assistant may invoke registered tools.
public sealed class ToolCallPolicy
- Inheritance
-
ToolCallPolicy
- Inherited Members
Remarks
This is a simple configuration object (POCO) read by the conversation/runtime loop. It does not enforce the policy by itself—the caller is responsible for honoring it (e.g., limiting the number of calls or forbidding tools for a turn).
Typical usage:
var policy = new ToolCallPolicy
{
Choice = ToolChoice.Auto,
MaxCallsPerTurn = 3
};
// Example: force a specific tool for this turn
policy.Choice = ToolChoice.Specific;
policy.ForcedToolName = "web_search";
Properties
- Choice
Controls whether the model may, must, or must not call tools for this turn, or whether it must call a specific tool.
- ForcedToolName
The exact tool name to enforce when Choice is Specific. Ignored for other choices. Name comparison should use
StringComparer.Ordinal
.
- MaxCallsPerTurn
Upper bound on the number of tool invocations permitted while resolving a single user turn. Helps prevent infinite tool-call loops. The default is 3.