Class: Pikuri::Agent::Event::Tokens

Inherits:
Data
  • Object
show all
Defined in:
lib/pikuri/agent/event.rb

Overview

Provider-reported token usage for one assistant turn, off a +RubyLLM::Message+'s tokens block. Emitted by after_message on every assistant turn (including pure tool-call turns, where context growth matters most).

Every count is Integer, nil; nil means the provider omitted the field (common on local llama.cpp/Ollama) and is treated as zero. +input+/+cached+/+cache_creation+ are exclusive slices of this turn's prompt and sum to its total size (llama.cpp + Anthropic shape; OpenAI nests cached inside input, so revisit the sum if pikuri ever targets it directly). cached still counts against the context window.

  • input — newly-processed (uncached) prompt tokens this turn.
  • output — tokens in this reply.
  • cached — prompt tokens served from the provider's cache.
  • cache_creation — prompt tokens written to the cache (Anthropic).
  • thinking — reasoning tokens (Anthropic thinking / OpenAI o-series); nil without a reasoning channel.
  • model_id — provider-side model name on the response.

Instance Attribute Summary collapse

Instance Attribute Details

#cache_creationObject (readonly)

Returns the value of attribute cache_creation

Returns:

  • (Object)

    the current value of cache_creation



99
100
101
# File 'lib/pikuri/agent/event.rb', line 99

def cache_creation
  @cache_creation
end

#cachedObject (readonly)

Returns the value of attribute cached

Returns:

  • (Object)

    the current value of cached



99
100
101
# File 'lib/pikuri/agent/event.rb', line 99

def cached
  @cached
end

#inputObject (readonly)

Returns the value of attribute input

Returns:

  • (Object)

    the current value of input



99
100
101
# File 'lib/pikuri/agent/event.rb', line 99

def input
  @input
end

#model_idObject (readonly)

Returns the value of attribute model_id

Returns:

  • (Object)

    the current value of model_id



99
100
101
# File 'lib/pikuri/agent/event.rb', line 99

def model_id
  @model_id
end

#outputObject (readonly)

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



99
100
101
# File 'lib/pikuri/agent/event.rb', line 99

def output
  @output
end

#thinkingObject (readonly)

Returns the value of attribute thinking

Returns:

  • (Object)

    the current value of thinking



99
100
101
# File 'lib/pikuri/agent/event.rb', line 99

def thinking
  @thinking
end