applyExclusiveToolPolicy checks whether toolCalls violate the exclusive-tool policy declared by exclusiveToolNames. When a violation is detected it synthesizes deterministic policy-error results for every tool call and records size/error metrics so the exclusivity failure mode is visible to operator
( toolCalls []fantasy.ToolCallContent, exclusiveToolNames map[string]bool, metrics *Metrics, provider, model string, )
| 1443 | // exclusivity failure mode is visible to operators. Returns |
| 1444 | // (results, true) on violation; (nil, false) otherwise. |
| 1445 | func applyExclusiveToolPolicy( |
| 1446 | toolCalls []fantasy.ToolCallContent, |
| 1447 | exclusiveToolNames map[string]bool, |
| 1448 | metrics *Metrics, |
| 1449 | provider, model string, |
| 1450 | ) ([]fantasy.ToolResultContent, bool) { |
| 1451 | blockingToolName, ok := firstExclusiveToolName(toolCalls, exclusiveToolNames) |
| 1452 | if !ok { |
| 1453 | return nil, false |
| 1454 | } |
| 1455 | results := exclusiveToolPolicyResults(toolCalls, exclusiveToolNames, blockingToolName) |
| 1456 | for _, tr := range results { |
| 1457 | recordToolResultMetrics(metrics, provider, model, tr) |
| 1458 | } |
| 1459 | return results, true |
| 1460 | } |
| 1461 | |
| 1462 | // recordToolResultMetrics observes tool result size and increments |
| 1463 | // tool_errors_total when the result carries an error output. Mirrors |