recordToolResultMetrics observes tool result size and increments tool_errors_total when the result carries an error output. Mirrors the metric-recording defer in executeSingleTool so that synthetic results (e.g. exclusive-tool policy errors) contribute to operator visibility.
(metrics *Metrics, provider, model string, tr fantasy.ToolResultContent)
| 1465 | // results (e.g. exclusive-tool policy errors) contribute to operator |
| 1466 | // visibility. |
| 1467 | func recordToolResultMetrics(metrics *Metrics, provider, model string, tr fantasy.ToolResultContent) { |
| 1468 | if metrics == nil { |
| 1469 | return |
| 1470 | } |
| 1471 | label := tr.ToolName |
| 1472 | if label == "" { |
| 1473 | label = "unknown" |
| 1474 | } |
| 1475 | metrics.ToolResultSizeBytes.WithLabelValues(provider, model, label).Observe( |
| 1476 | float64(ToolResultSize(tr)), |
| 1477 | ) |
| 1478 | if _, ok := tr.Result.(fantasy.ToolResultOutputContentError); ok { |
| 1479 | metrics.RecordToolError(provider, model, label) |
| 1480 | } |
| 1481 | } |
| 1482 | |
| 1483 | func firstExclusiveToolName( |
| 1484 | toolCalls []fantasy.ToolCallContent, |
no test coverage detected