Package ai.platon.pulsar.coding
Class CodingTokenStats
-
- All Implemented Interfaces:
public final class CodingTokenStatsPer-method token statistics accumulator for the
codingdomain.Records, for every tool call: input (serialized arguments) and output (result string) size in chars and estimated tokens, call/error counts, duration, and max sizes. Thread-safe; fixed memory footprint (one entry per distinct method name).
Consumed by
coding.tokenStatsso the agent and developers can audit which coding tools consume the most context window.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classCodingTokenStats.MethodStatAggregated statistics for one tool method. Immutable snapshot fields; safe to read.
-
Constructor Summary
Constructors Constructor Description CodingTokenStats()
-
Method Summary
Modifier and Type Method Description final BooleanisEmpty()True when nothing has been recorded yet. final Unitrecord(String method, String input, String output, Boolean error, Long millis)Record one tool call. final List<CodingTokenStats.MethodStat>snapshot()Immutable per-method snapshots, sorted by output tokens (desc). final Unitreset()Drop all recorded statistics and restart the "since" clock. final Stringreport()Human-readable report: one line per method (sorted by output tokens), plus a total line. -
-
Method Detail
-
record
final Unit record(String method, String input, String output, Boolean error, Long millis)
Record one tool call.
- Parameters:
method- tool method name (e.g.input- serialized arguments the LLM sent (null → 0)output- result text returned to the LLM (null → 0)error- true when the call failedmillis- wall-clock duration of the call
-
snapshot
final List<CodingTokenStats.MethodStat> snapshot()
Immutable per-method snapshots, sorted by output tokens (desc).
-
-
-
-