fix(chat): nil tool name in on_tool_output#3046
Merged
olimorris merged 1 commit intoolimorris:mainfrom Apr 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes the on_tool_output callback tool argument being nil by passing the resolved tool’s name instead of the raw LLM tool-call object’s (missing) name.
Changes:
- Update
Chat:add_tool_outputto passtool.nameinto callback args. - Add a regression test asserting correct callback args and that callback mutations affect stored message content.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lua/codecompanion/interactions/chat/init.lua | Fix callback args to use tool.name so args.tool is not nil. |
| tests/interactions/chat/tools/builtin/test_tool_output.lua | Add regression test ensuring on_tool_output receives correct args and can mutate output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
Great spot and thanks for the fix. Let's move the test to |
16772d8 to
d492d30
Compare
Contributor
Author
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix the
toolparameter inon_tool_outputcallback always beingnil.Root cause: In
Chat:add_tool_outputmethod, the callback args usedtool_call.name, buttool_callis the raw LLM tool call object (i.e.,tool.function_call) which doesn't have a top-level.nameproperty.Fix: Changed
tool_call.nametotool.name, which is correctly set in both_handle_tool_errorand_resolve_and_prepare_tool.Files changed:
lua/codecompanion/interactions/chat/init.lua— single-line fixtests/interactions/chat/tools/builtin/test_tool_output.lua— added test for callback parametersAI Usage
Used CodeCompanion + GLM5 to help diagnose the issue and write the test case.
Related Issue(s)
N/A
Screenshots
N/A
Checklist
make allto ensure docs are generated, tests pass and StyLua has formatted the code