Skip to content

AgentPrismToolUsage

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Lets a tool report non-token usage from its own body.

public static class AgentPrismToolUsage

objectAgentPrismToolUsage

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

AgentPrismToolUsage.Report(new ToolCallUsage
{
Unit = ToolUsageUnits.Characters,
Quantity = audio.CharactersBilled ?? request.Text.Length,
Cost = price,
Currency = "USD",
IsEstimated = audio.CharactersBilled is null,
});

Speech synthesis is billed by character and speech recognition by second. Neither is a token and cannot be written to the cost columns of the runs table. The measurement attaches to the current call’s ToolInvocationRecord.

It reads the call identifier from FunctionInvokingChatClient.CurrentContext. This was verified by measurement on 2026-08-05. The AIFunctionArguments.Context dictionary is null and does not carry the call identifier, while the static context is populated in the tool body. Dependencies resolve through AIFunctionArguments.Services.

Reports usage for the current tool call.

public static bool Report(ToolCallUsage usage)

usage ToolCallUsage

The usage measurement.

bool

true when the measurement is attached to a call. Returns false when run recording is disabled or the call is not in a tool context.

This method never throws, except for an empty argument. A false result does not interrupt the tool. Observability does not break functionality. This is the same rule that prevents a store error from stopping a run.

ArgumentNullException

usage is null.