Skip to content

Commit bc5ec92

Browse files
authored
fix(tools): additional resiliency (#1987)
Co-authored-by: Oli Morris <olimorris@users.noreply.github.com>
1 parent 705f0cf commit bc5ec92

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lua/codecompanion/strategies/chat/tools/init.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ function Tools:execute(chat, tools)
130130
---@param orchestrator CodeCompanion.Tools.Orchestrator The orchestrator instance
131131
---@param tool table The tool to run
132132
local function enqueue_tool(orchestrator, tool)
133-
if self.status == CONSTANTS.STATUS_ERROR then
134-
return
135-
end
136-
137133
local name = tool["function"].name
138134
local tool_config = self.tools_config[name]
139135
local function handle_missing_tool(tool_call, err_message)

lua/codecompanion/strategies/chat/tools/orchestrator.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,11 @@ end
339339
---Close the execution of the tool
340340
---@return nil
341341
function Orchestrator:close()
342-
--TODO: This is a workaround that avoids the close method being called more than once
343342
if self.tool then
344343
log:debug("Orchestrator:close")
345-
self.handlers.on_exit()
344+
pcall(function()
345+
self.handlers.on_exit()
346+
end)
346347
utils.fire("ToolFinished", { id = self.id, name = self.tool.name, bufnr = self.tools.bufnr })
347348
self.tool = nil
348349
end

0 commit comments

Comments
 (0)