Class: AgentRuntime::Executor
- Inherits:
-
Object
- Object
- AgentRuntime::Executor
- Defined in:
- lib/agent_runtime/executor.rb
Overview
Executes tool calls via ToolRegistry based on agent decisions.
This class is responsible for executing the actions decided by the planner. It normalizes parameters and delegates to the ToolRegistry for actual execution.
Instance Method Summary collapse
-
#execute(decision, state: nil) ⇒ Hash
Execute a decision by calling the appropriate tool.
-
#initialize(tool_registry:) ⇒ Executor
constructor
Initialize a new Executor instance.
Constructor Details
#initialize(tool_registry:) ⇒ Executor
Initialize a new Executor instance.
17 18 19 |
# File 'lib/agent_runtime/executor.rb', line 17 def initialize(tool_registry:) @tools = tool_registry end |
Instance Method Details
#execute(decision, state: nil) ⇒ Hash
Execute a decision by calling the appropriate tool.
If the action is “finish”, returns a done hash without executing any tool. Otherwise, normalizes parameters and calls the tool from the registry.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/agent_runtime/executor.rb', line 40 def execute(decision, state: nil) # rubocop:disable Lint/UnusedMethodArgument case decision.action when "finish" { done: true } else normalized_params = normalize_params(decision.params || {}) @tools.call(decision.action, normalized_params) end rescue StandardError => e raise ExecutionError, e. end |