fix(agents): skip tool calls without valid name on model switch#43985
fix(agents): skip tool calls without valid name on model switch#43985guang384 wants to merge 9 commits intoopenclaw:mainfrom
Conversation
Fixes openclaw#43930 When switching between models (e.g., Gemini → Grok → Gemini), the context may contain function_response entries that were valid for the previous model but cause errors for Gemini API with 'Name cannot be empty'. This fix skips tool calls without valid name during message conversion, preventing the INVALID_ARGUMENT error from Gemini API. Related to PR openclaw#41173 which added stripRuntimeModelState() for session reset, but model switching is a different scenario that needs separate handling.
Greptile SummaryThis PR correctly completes the fix for the Key changes:
Confidence Score: 4/5
Last reviewed commit: 5be87be |
This comment was marked as spam.
This comment was marked as spam.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@greptileai review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1aaed1cdc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b9c24fd39
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 557d3e9d91
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22c1c66023
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@greptileai review |
Summary
Fixes #43930
Problem
When switching between models (e.g., Gemini → Grok → Gemini), the context may contain function_response entries that were valid for the previous model but cause errors for Gemini API with:
Root Cause
When switching models mid-session, the conversation history contains tool calls from the previous model. These may have different format requirements. Gemini API requires function_response.name to be non-empty, but other models may allow empty names.
Solution
Skip tool calls without valid name during message conversion in convertMessagesToInputItems(). This prevents the INVALID_ARGUMENT error from Gemini API.
Related
Test