[data] fix LFM2 tool extractor dropping positional arguments#10594
[data] fix LFM2 tool extractor dropping positional arguments#10594he-yufeng wants to merge 1 commit into
Conversation
Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request updates the LFM2 tool extractor to bail to raw content when positional arguments are present, preventing them from being silently dropped, and adds corresponding unit tests. The review feedback suggests extending this safety check to also bail when double-starred keyword arguments (**kwargs) are present, as they result in None keys in the AST and can cause serialization errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if node.args: | ||
| return content |
There was a problem hiding this comment.
In Python's AST, double-starred keyword arguments (e.g., **kwargs) are represented as ast.keyword nodes where arg is None. If a tool call contains **kwargs, keyword.arg will be None, which would lead to setting None as a key in args_dict and subsequently causing a TypeError during json.dumps (or producing an invalid JSON key "null"). To prevent this, we should also bail to the raw content if any keyword argument has arg is None.
| if node.args: | |
| return content | |
| if node.args or any(keyword.arg is None for keyword in node.keywords): | |
| return content |
What does this PR do?
LFM2ToolUtils.tool_extractorparses a generated Pythonic tool call and only readsnode.keywords, so any positional argument is silently dropped:That turns a malformed call into a clean-looking one with missing arguments, which then gets executed with the wrong inputs. Positional values can't be mapped to the tool's named parameters at this point (there's no schema here), so this PR bails to the raw content instead — the same fallback the method already uses for an unparseable call or a bad argument value. This matches the recent SeedToolUtils fix (#10408) where the extractor returns content rather than emitting a broken call.
Before submitting
test_lfm2_tool_extractor_positional_argsintests/data/test_formatter.py, covering positional-only and mixed positional/keyword calls)