Class: ActionAgent::AgentGeneration
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActionAgent::AgentGeneration
- Defined in:
- app/models/action_agent/agent_generation.rb
Overview
One LLM generation call within an agent conversation context. From the solid_agent install generator, extended with trace_id (joins to active_agent_telemetry_traces) and the SolidAgent provenance hash.
Instance Method Summary collapse
-
#cache_hit? ⇒ Boolean
Provider prompt-cache hit on this generation?.
- #completed? ⇒ Boolean
- #has_tool_calls? ⇒ Boolean
-
#telemetry_trace ⇒ Object
The telemetry trace this generation belongs to, when recorded.
-
#thinking? ⇒ Boolean
Extended thinking captured?.
- #total_tokens ⇒ Object
- #truncated? ⇒ Boolean
Methods inherited from ApplicationRecord
Instance Method Details
#cache_hit? ⇒ Boolean
Provider prompt-cache hit on this generation?
32 33 34 |
# File 'app/models/action_agent/agent_generation.rb', line 32 def cache_hit? cached_tokens.to_i.positive? end |
#completed? ⇒ Boolean
23 24 25 |
# File 'app/models/action_agent/agent_generation.rb', line 23 def completed? finish_reason == "stop" end |
#has_tool_calls? ⇒ Boolean
19 20 21 |
# File 'app/models/action_agent/agent_generation.rb', line 19 def has_tool_calls? tool_calls.present? && tool_calls.any? end |
#telemetry_trace ⇒ Object
The telemetry trace this generation belongs to, when recorded.
42 43 44 45 46 |
# File 'app/models/action_agent/agent_generation.rb', line 42 def telemetry_trace return nil if trace_id.blank? ActionAgent.trace_model.find_by(trace_id: trace_id) end |
#thinking? ⇒ Boolean
Extended thinking captured?
37 38 39 |
# File 'app/models/action_agent/agent_generation.rb', line 37 def thinking? reasoning_tokens.to_i.positive? end |
#total_tokens ⇒ Object
15 16 17 |
# File 'app/models/action_agent/agent_generation.rb', line 15 def total_tokens input_tokens + output_tokens end |
#truncated? ⇒ Boolean
27 28 29 |
# File 'app/models/action_agent/agent_generation.rb', line 27 def truncated? finish_reason == "length" end |