Class: Xeno::Action

Inherits:
ApplicationRecord show all
Defined in:
app/models/xeno/action.rb

Overview

One requested tool call: the durability checkpoint and (in M4) the approval state. A completed action means "executed AND its result is in the transcript" — the two are committed in one transaction, so replay logic can trust either signal.

Constant Summary collapse

STATUSES =
%w[pending pending_approval approved denied completed failed].freeze
KINDS =
%w[tool question].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.record!(turn, tool_call, kind: "tool") ⇒ Object



15
16
17
18
19
20
21
# File 'app/models/xeno/action.rb', line 15

def self.record!(turn, tool_call, kind: "tool")
  find_or_create_by!(turn: turn, tool_call_id: tool_call.id) do |action|
    action.tool_name = tool_call.name
    action.kind = kind
    action.input = tool_call.arguments
  end
end

Instance Method Details

#awaiting_input?Boolean

Returns:

  • (Boolean)


24
# File 'app/models/xeno/action.rb', line 24

def awaiting_input? = %w[pending_approval].include?(status)

#completed?Boolean

Returns:

  • (Boolean)


23
# File 'app/models/xeno/action.rb', line 23

def completed? = status == "completed"