Class: ActionAgent::AgentGeneration

Inherits:
ApplicationRecord show all
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

Methods inherited from ApplicationRecord

for_owner, owner_association

Instance Method Details

#cache_hit?Boolean

Provider prompt-cache hit on this generation?

Returns:

  • (Boolean)


32
33
34
# File 'app/models/action_agent/agent_generation.rb', line 32

def cache_hit?
  cached_tokens.to_i.positive?
end

#completed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/action_agent/agent_generation.rb', line 23

def completed?
  finish_reason == "stop"
end

#has_tool_calls?Boolean

Returns:

  • (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_traceObject

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?

Returns:

  • (Boolean)


37
38
39
# File 'app/models/action_agent/agent_generation.rb', line 37

def thinking?
  reasoning_tokens.to_i.positive?
end

#total_tokensObject



15
16
17
# File 'app/models/action_agent/agent_generation.rb', line 15

def total_tokens
  input_tokens + output_tokens
end

#truncated?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/action_agent/agent_generation.rb', line 27

def truncated?
  finish_reason == "length"
end