Module: RubyPi::Agent

Defined in:
lib/ruby_pi/agent/core.rb,
lib/ruby_pi/agent/core.rb,
lib/ruby_pi/agent/loop.rb,
lib/ruby_pi/agent/state.rb,
lib/ruby_pi/agent/events.rb,
lib/ruby_pi/agent/result.rb

Overview

Module-level convenience method for creating Agent instances without referencing Agent::Core directly. Allows ‘RubyPi::Agent.new(…)`.

Defined Under Namespace

Modules: EventEmitter Classes: Core, Loop, Result, State

Constant Summary collapse

EVENTS =

Canonical event types emitted during the agent lifecycle. Each symbol represents a specific moment or occurrence:

  • :text_delta — An incremental text chunk from the LLM stream.

  • :tool_execution_start — A tool is about to be executed.

  • :tool_execution_end — A tool has finished executing.

  • :turn_start — A new think-act-observe cycle is beginning.

  • :turn_end — A think-act-observe cycle has completed.

  • :agent_end — The agent has finished its run (final event).

  • :error — A recoverable or fatal error occurred.

  • :compaction — Context compaction was triggered.

%i[
  text_delta
  tool_execution_start
  tool_execution_end
  turn_start
  turn_end
  agent_end
  error
  compaction
].freeze

Class Method Summary collapse

Class Method Details

.new(**args) ⇒ RubyPi::Agent::Core

Creates a new Agent::Core instance. This is the recommended entry point for building agents.

Examples:

agent = RubyPi::Agent.new(
  system_prompt: "You are helpful.",
  model: model,
  tools: registry
)

Parameters:

  • args (Hash)

    constructor arguments forwarded to Agent::Core.new

Returns:



170
171
172
# File 'lib/ruby_pi/agent/core.rb', line 170

def new(**args)
  Core.new(**args)
end