Class: SkillBench::Agent::ReactAgent
- Inherits:
-
Object
- Object
- SkillBench::Agent::ReactAgent
- 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
-
.call(params) ⇒ Hash
Starts the ReAct loop for a specific task.
Instance Method Summary collapse
-
#call ⇒ Hash
Executes the ReAct loop.
-
#initialize(params) ⇒ ReactAgent
constructor
A new instance of ReactAgent.
Constructor Details
#initialize(params) ⇒ ReactAgent
Returns a new instance of ReactAgent.
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.
24 25 26 |
# File 'lib/skill_bench/agent/react_agent.rb', line 24 def self.call(params) new(params).call end |
Instance Method Details
#call ⇒ Hash
Executes the ReAct loop.
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 |