Class: Crimson::Agent::ToolExecutor
- Inherits:
-
Object
- Object
- Crimson::Agent::ToolExecutor
- Defined in:
- lib/crimson/agent/tool_executor.rb
Overview
Executes tool calls with parallel/sequential modes, hooks, and abort support.
Instance Method Summary collapse
-
#execute(tool_calls, history) ⇒ Array<Hash>
Execute a list of tool calls.
-
#initialize(tool_registry, events, before_hook: nil, after_hook: nil, abort_signal: nil) ⇒ ToolExecutor
constructor
A new instance of ToolExecutor.
Constructor Details
#initialize(tool_registry, events, before_hook: nil, after_hook: nil, abort_signal: nil) ⇒ ToolExecutor
Returns a new instance of ToolExecutor.
14 15 16 17 18 19 20 |
# File 'lib/crimson/agent/tool_executor.rb', line 14 def initialize(tool_registry, events, before_hook: nil, after_hook: nil, abort_signal: nil) @tool_registry = tool_registry @events = events @before_hook = before_hook @after_hook = after_hook @abort_signal = abort_signal end |
Instance Method Details
#execute(tool_calls, history) ⇒ Array<Hash>
Execute a list of tool calls. Tools marked as sequential run one at a time; others run in parallel.
27 28 29 30 31 32 33 34 35 |
# File 'lib/crimson/agent/tool_executor.rb', line 27 def execute(tool_calls, history) sequential = tool_calls.any? { |tc| tool_sequential?(tc) } if sequential execute_sequential(tool_calls, history) else execute_parallel(tool_calls, history) end end |