Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 9, 2025

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:

  • All content is wrapped in <think> tags (thinking/reasoning content)
  • No regular message content exists outside the thinking tags
  • Tool calls are embedded within the thinking 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:

  1. Track whether regular content or tool calls exist outside thinking tags
  2. When only thinking content exists, extract tool calls from within the thinking content
  3. Parse common tool call patterns (XML-like tags) from thinking content
  4. Emit the extracted tool calls as tool_call_partial events for the NativeToolCallParser

Changes

  • Modified base-openai-compatible-provider.ts to extract tool calls from thinking content
  • Added comprehensive tests to verify the new functionality
  • Ensured backward compatibility with existing behavior

Testing

  • Added 5 new test cases covering various scenarios
  • All existing tests pass without regression
  • Tests verify tool call extraction, parsing, and error handling

Feedback and guidance are welcome!

…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
@roomote
Copy link
Contributor Author

roomote bot commented Dec 9, 2025

Rooviewer Clock   See task on Roo Cloud

All issues from previous review have been addressed.

  • Incomplete tool list in isKnownTool - missing 8 tools that exist in @roo-code/types
  • Incomplete primaryParams mapping - only covers 9 of 22 tools
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines 273 to 291
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())
}
Copy link
Contributor Author

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.

Suggested change
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.

Comment on lines 314 to 325
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",
}

Copy link
Contributor Author

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.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 9, 2025
@bozoweed
Copy link

@roomote instead hardcode get the current avaible tools include mcp ones dynamicly

@roomote
Copy link
Contributor Author

roomote bot commented Dec 10, 2025

Fixaroo Clock   See task on Roo Cloud

Fixed the reported issues. All local checks passed.

View commit | Revert commit

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

4 participants