Class: Boxcars::AgentEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/boxcars/agent_event.rb

Overview

Lightweight immutable event emitted during agent execution. Captures what the agent is doing at each step without affecting execution.

Constant Summary collapse

TYPES =
%i[
  agent_start
  llm_call_start
  llm_response
  tool_call_start
  tool_call_blocked
  tool_call_end
  handoff
  agent_complete
  agent_error
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, data: {}, iteration: 0) ⇒ AgentEvent

Returns a new instance of AgentEvent.

Parameters:

  • type (Symbol)

    One of TYPES

  • data (Hash) (defaults to: {})

    Event-specific payload (frozen on init)

  • iteration (Integer) (defaults to: 0)

    Current agent loop iteration

Raises:

  • (::ArgumentError)


24
25
26
27
28
29
30
31
# File 'lib/boxcars/agent_event.rb', line 24

def initialize(type:, data: {}, iteration: 0)
  raise ::ArgumentError, "Unknown event type: #{type}" unless TYPES.include?(type)

  @type = type
  @data = data.freeze
  @timestamp = Time.now
  @iteration = iteration
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



19
20
21
# File 'lib/boxcars/agent_event.rb', line 19

def data
  @data
end

#iterationObject (readonly)

Returns the value of attribute iteration.



19
20
21
# File 'lib/boxcars/agent_event.rb', line 19

def iteration
  @iteration
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



19
20
21
# File 'lib/boxcars/agent_event.rb', line 19

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



19
20
21
# File 'lib/boxcars/agent_event.rb', line 19

def type
  @type
end