Class: SkillBench::Agent::ReactAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/agent/react_agent.rb,
lib/skill_bench/agent/react_agent/step.rb,
lib/skill_bench/agent/react_agent/loop_runner.rb,
lib/skill_bench/agent/react_agent/tool_executor.rb

Overview

An agent that follows the ReAct (Reasoning and Acting) loop pattern. It executes a given task by repeatedly thinking, invoking tools, and observing the results until it finishes the task or reaches the maximum number of iterations.

Defined Under Namespace

Classes: LoopRunner, Step, ToolExecutor

Constant Summary collapse

MAX_ITERATIONS_REACHED =

Error message returned when the ReAct loop reaches max iterations.

'Reached max iterations without finishing.'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ ReactAgent

Returns a new instance of ReactAgent.

Parameters:

  • params (Hash)

    The configuration for the agent.



29
30
31
32
33
34
35
36
# File 'lib/skill_bench/agent/react_agent.rb', line 29

def initialize(params)
  @system_prompt = params[:system_prompt]
  @initial_prompt = params[:initial_prompt]
  @max_iterations = params[:max_iterations] || 25
  @working_dir = params[:working_dir] || Dir.pwd
  @container_id = params[:container_id]
  @client_params = params[:client_params] || {}
end

Class Method Details

.call(params) ⇒ Hash

Starts the ReAct loop for a specific task.

Parameters:

  • params (Hash)

    The configuration for the agent.

Options Hash (params):

  • :system_prompt (String)

    The instructions establishing the agent’s persona and rules.

  • :initial_prompt (String)

    The user task the agent must complete.

  • :max_iterations (Integer) — default: 25

    The maximum allowed steps before aborting.

  • :working_dir (String) — default: Dir.pwd

    The directory where tools should operate.

  • :client_params (Hash) — default: {}

    Configuration passed to the Client (e.g., model).

Returns:

  • (Hash)

    A result hash with :success, and :response payload containing the final answer.



24
25
26
# File 'lib/skill_bench/agent/react_agent.rb', line 24

def self.call(params)
  new(params).call
end

Instance Method Details

#callHash

Executes the ReAct loop.

Returns:

  • (Hash)

    The standardized result hash indicating success or failure.



41
42
43
44
# File 'lib/skill_bench/agent/react_agent.rb', line 41

def call
  config = build_step_config
  LoopRunner.call(@initial_prompt, @max_iterations, config)
end