Skip to content

Commit 7ea5598

Browse files
Copilotolimorris
andcommitted
Fix tool loading error handling and edit tracking robustness
Co-authored-by: olimorris <[email protected]>
1 parent 00b4f76 commit 7ea5598

File tree

1 file changed

+13
-1
lines changed
  • lua/codecompanion/strategies/chat/tools

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,18 @@ end
155155
function Tools:_start_edit_tracking(tools)
156156
for _, tool in ipairs(tools) do
157157
local tool_name = tool["function"].name
158-
local tool_args, _ = self:_parse_tool_arguments(tool)
158+
local tool_args = tool["function"].arguments
159+
160+
-- Handle argument parsing more robustly, like the original code
161+
if type(tool_args) == "string" then
162+
local success, decoded = pcall(vim.json.decode, tool_args)
163+
if success then
164+
tool_args = decoded
165+
else
166+
tool_args = nil
167+
end
168+
end
169+
159170
EditTracker.start_tool_monitoring(tool_name, self.chat, tool_args)
160171
end
161172
end
@@ -445,6 +456,7 @@ function Tools.resolve(tool)
445456
local err
446457
module, err = loadfile(callback)
447458
if err then
459+
log:error("[Tools] Failed to load tool from %s: %s", callback, err)
448460
return nil
449461
end
450462

0 commit comments

Comments
 (0)