Class: BashTool
- Inherits:
-
LlmGateway::Tool
- Object
- LlmGateway::Tool
- BashTool
- Defined in:
- lib/llm_gateway/agents/tools/bash_tool.rb
Instance Method Summary collapse
Methods inherited from LlmGateway::Tool
cache, definition, description, #initialize, input_schema, name, tool_name, #tool_result
Constructor Details
This class inherits a constructor from LlmGateway::Tool
Instance Method Details
#execute(input, tool_use_id:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/llm_gateway/agents/tools/bash_tool.rb', line 21 def execute(input, tool_use_id:) command = input[:command] timeout = input[:timeout] result = run_command(command, timeout) out = format_output(result[:output], empty_text: result[:timed_out] ? "" : "(no output)") if result[:timed_out] return tool_result(append_status(out, "Command timed out after #{timeout} seconds"), tool_use_id: tool_use_id) end if result[:exit_status] && result[:exit_status] != 0 return tool_result(append_status(out, "Command exited with code #{result[:exit_status]}"), tool_use_id: tool_use_id) end tool_result(out, tool_use_id: tool_use_id) rescue StandardError => e tool_result(e., tool_use_id: tool_use_id) end |