Table of Contents

Class UsageTools

Namespace
JD.AI.Core.Tools
Assembly
JD.AI.Core.dll

Tools for tracking token usage and costs across the session.

[ToolPlugin("usage", RequiresInjection = true)]
public sealed class UsageTools
Inheritance
UsageTools
Inherited Members

Constructors

UsageTools(ICostEstimator?)

public UsageTools(ICostEstimator? costEstimator = null)

Parameters

costEstimator ICostEstimator

Methods

GetUsage()

[KernelFunction("get_usage")]
[ToolSafetyTier(SafetyTier.AutoApprove)]
public string GetUsage()

Returns

string

RecordUsage(long, long, int)

Records token usage for a turn. Called by the agent loop after each response.

public void RecordUsage(long promptTokens, long completionTokens, int toolCalls)

Parameters

promptTokens long
completionTokens long
toolCalls int

ResetUsage()

[KernelFunction("reset_usage")]
[ToolSafetyTier(SafetyTier.ConfirmOnce)]
public string ResetUsage()

Returns

string

SetModel(ProviderModelInfo)

Sets the current model for accurate cost calculation when metadata is available.

public void SetModel(ProviderModelInfo model)

Parameters

model ProviderModelInfo