Class CodingTokenStats

  • All Implemented Interfaces:

    
    public final class CodingTokenStats
    
                        

    Per-method token statistics accumulator for the coding domain.

    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.tokenStats so 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 class CodingTokenStats.MethodStat

      Aggregated statistics for one tool method. Immutable snapshot fields; safe to read.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Boolean isEmpty
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Boolean isEmpty() True when nothing has been recorded yet.
      final Unit record(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 Unit reset() Drop all recorded statistics and restart the "since" clock.
      final String report() Human-readable report: one line per method (sorted by output tokens), plus a total line.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CodingTokenStats

        CodingTokenStats()
    • Method Detail

      • isEmpty

         final Boolean isEmpty()

        True when nothing has been recorded yet.

      • 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 failed
        millis - wall-clock duration of the call
      • reset

         final Unit reset()

        Drop all recorded statistics and restart the "since" clock.

      • report

         final String report()

        Human-readable report: one line per method (sorted by output tokens), plus a total line. Compact — it is itself returned to the LLM.