-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: extract tool calls from thinking content in OpenAI Compatible provider #9964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ovider - Add logic to detect when only thinking content exists without regular content - Extract and parse tool calls embedded within thinking tags - Support common tool call patterns in thinking content - Add comprehensive tests for the new functionality Fixes #9959
All issues from previous review have been addressed.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| private isKnownTool(name: string): boolean { | ||
| const knownTools = [ | ||
| "read_file", | ||
| "write_to_file", | ||
| "apply_diff", | ||
| "execute_command", | ||
| "list_files", | ||
| "search_files", | ||
| "ask_followup_question", | ||
| "attempt_completion", | ||
| "update_todo_list", | ||
| "list_code_definition_names", | ||
| "use_mcp_tool", | ||
| "switch_mode", | ||
| "new_task", | ||
| "fetch_instructions", | ||
| ] | ||
| return knownTools.includes(name.toLowerCase()) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hardcoded list is missing 8 tools that exist in packages/types/src/tool.ts: search_and_replace, search_replace, apply_patch, browser_action, access_mcp_resource, codebase_search, run_slash_command, and generate_image. Tool calls for these tools in thinking content will be silently ignored. Consider importing toolNames from @roo-code/types instead of hardcoding to stay in sync with the codebase.
| private isKnownTool(name: string): boolean { | |
| const knownTools = [ | |
| "read_file", | |
| "write_to_file", | |
| "apply_diff", | |
| "execute_command", | |
| "list_files", | |
| "search_files", | |
| "ask_followup_question", | |
| "attempt_completion", | |
| "update_todo_list", | |
| "list_code_definition_names", | |
| "use_mcp_tool", | |
| "switch_mode", | |
| "new_task", | |
| "fetch_instructions", | |
| ] | |
| return knownTools.includes(name.toLowerCase()) | |
| } | |
| private isKnownTool(name: string): boolean { | |
| const knownTools = [ | |
| "read_file", | |
| "write_to_file", | |
| "apply_diff", | |
| "search_and_replace", | |
| "search_replace", | |
| "apply_patch", | |
| "execute_command", | |
| "list_files", | |
| "search_files", | |
| "ask_followup_question", | |
| "attempt_completion", | |
| "update_todo_list", | |
| "list_code_definition_names", | |
| "use_mcp_tool", | |
| "access_mcp_resource", | |
| "switch_mode", | |
| "new_task", | |
| "fetch_instructions", | |
| "browser_action", | |
| "codebase_search", | |
| "run_slash_command", | |
| "generate_image", | |
| ] | |
| return knownTools.includes(name.toLowerCase()) | |
| } |
Fix it with Roo Code or mention @roomote and request a fix.
| const primaryParams: Record<string, string> = { | ||
| read_file: "files", | ||
| write_to_file: "content", | ||
| apply_diff: "diff", | ||
| execute_command: "command", | ||
| list_files: "path", | ||
| search_files: "regex", | ||
| ask_followup_question: "question", | ||
| attempt_completion: "result", | ||
| update_todo_list: "todos", | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mapping only covers 9 tools. Tools like browser_action, codebase_search, search_and_replace, apply_patch, etc. will fall back to using content as the parameter name, which may not match their expected schema. Consider expanding this mapping to cover additional tools or documenting this limitation.
Fix it with Roo Code or mention @roomote and request a fix.
|
@roomote instead hardcode get the current avaible tools include mcp ones dynamicly |
Fixed the reported issues. All local checks passed. |
…list - Import toolNames from @roo-code/types as the source of truth - Update isKnownTool to use toolNames array and detect MCP tools (mcp_* prefix) - Complete primaryParams mapping for all 22 tools
This PR attempts to address Issue #9959.
Problem
When using OpenAI Compatible API with thinking models (like kimi-k2-thinking), the model may return responses where:
<think>tags (thinking/reasoning content)Currently, this causes the request to be marked as failed even though valid tool calls exist in the thinking content.
Solution
Modified the OpenAI Compatible provider's response handling to:
tool_call_partialevents for the NativeToolCallParserChanges
base-openai-compatible-provider.tsto extract tool calls from thinking contentTesting
Feedback and guidance are welcome!