Skip to content

Commit 0be48d7

Browse files
committed
fix(nvim): fix codecompanion tool error handling.
1 parent d36ef41 commit 0be48d7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lua/vectorcode/integrations/codecompanion/func_calling_tool.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ return check_cli_wrap(function(opts)
7878
then
7979
vim.list_extend(args, { "--project_root", action.options.project_root })
8080
else
81-
agent.chat:add_message(
82-
{ role = "user", content = "INVALID PROJECT ROOT! USE THE LS COMMAND!" },
83-
{ visible = false }
84-
)
81+
return {
82+
status = "error",
83+
data = "INVALID PROJECT ROOT! USE THE LS COMMAND!",
84+
}
8585
end
8686
end
8787

@@ -244,7 +244,7 @@ return check_cli_wrap(function(opts)
244244
stderr = cc_common.flatten_table_to_string(stderr)
245245
agent.chat:add_tool_output(
246246
self,
247-
string.format("**VectorCode Tool**: Failed with error:\n", stderr)
247+
string.format("**VectorCode Tool**: Failed with error:\n```\n%s\n```", stderr)
248248
)
249249
end,
250250
---@param agent CodeCompanion.Agent

lua/vectorcode/integrations/codecompanion/legacy_tool.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ return check_cli_wrap(function(opts)
7070
vim.list_extend(args, { "--project_root", action.options.project_root })
7171
vim.list_extend(args, { "--absolute" })
7272
else
73-
agent.chat:add_message(
74-
{ role = "user", content = "INVALID PROJECT ROOT! USE THE LS COMMAND!" },
75-
{ visible = false }
76-
)
73+
return {
74+
status = "error",
75+
data = "INVALID PROJECT ROOT! USE THE LS COMMAND!",
76+
}
7777
end
7878
end
7979

@@ -281,7 +281,7 @@ Remember:
281281
agent.chat:add_message({
282282
role = "user",
283283
content = string.format(
284-
"VectorCode tool failed with the following error:\n",
284+
"VectorCode tool failed with the following error:\n```\n%s\n```",
285285
stderr
286286
),
287287
}, { visible = false })

0 commit comments

Comments
 (0)