-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: preserve dynamic MCP tool names in native mode API history #9559
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
Merged
Conversation
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
Contributor
Re-review completed. All previously identified issues have been resolved.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
mrubens
approved these changes
Nov 25, 2025
18a62b6 to
bfecce5
Compare
Fixes issue where dynamic MCP tools (mcp_serverName_toolName) were being converted to 'use_mcp_tool' in API conversation history, causing the model to mistakenly think 'use_mcp_tool' is a valid tool in native mode. Changes: - Added McpToolUse type to preserve original tool names in native mode - Updated NativeToolCallParser to return McpToolUse for dynamic MCP tools - Modified presentAssistantMessage to handle mcp_tool_use type - Updated Task.ts to store McpToolUse with original names in API history - Added McpToolUse to AssistantMessageContent type union The XML mode behavior remains unchanged - it continues using use_mcp_tool.
…structions
- Refactored accessMcpResourceTool to extend BaseTool class
- Added native tool definition for access_mcp_resource
- Updated MCP servers section to provide different instructions based on protocol
- XML mode: mentions use_mcp_tool wrapper
- Native mode: explains mcp_{server}_{tool} naming pattern
- Registered access_mcp_resource in native tools list
- Simplify MCP tool schema to pass arguments directly (no toolInputProps wrapper) - Extract server_name/tool_name from function name (mcp_serverName_toolName) - Add finalizeRawChunks() call after stream ends to properly convert MCP tools - Add dynamic MCP tool validation against mcp group in mode permissions - Fix NativeToolCallParser to support string names for dynamic MCP tools
652f19a to
626791e
Compare
mrubens
approved these changes
Nov 25, 2025
mini2s
added a commit
to zgsm-ai/costrict
that referenced
this pull request
Nov 26, 2025
* feat(core): enhance attempt_completion parsing with flexible result handling * test(core): update test configurations and CSP settings * feat: add Google Tag Manager to marketing website (RooCodeInc#9148) * feat: add Google Tag Manager to marketing website using Next.js Script component * refactor: remove Google Ads implementation in favor of Tag Manager * fix: wrap GTM script in consent-checking client component for GDPR compliance --------- Co-authored-by: Roo Code <[email protected]> * IPC command for sending messages to the current task (RooCodeInc#9149) * fix: prevent command_output ask from blocking in cloud/headless environments (RooCodeInc#9152) * chore: add changeset for v3.31.1 (RooCodeInc#9153) * Release: v1.85.0 (RooCodeInc#9155) * Gate XML out when native tool protocol is ON (RooCodeInc#9107) * Add native tool definitions (RooCodeInc#9156) * feat: sync reviewer landing page copy - variant B to variant A (RooCodeInc#9158) - Updated variant A content to match variant B messaging - Both variants now show the same improved copy focused on catching meaningful bugs - Emphasizes depth over token-saving and repository-aware analysis Co-authored-by: Roo Code <[email protected]> * feat: sync reviewer landing page copy - variant B to variant A (RooCodeInc#9158) - Updated variant A content to match variant B messaging - Both variants now show the same improved copy focused on catching meaningful bugs - Emphasizes depth over token-saving and repository-aware analysis Co-authored-by: Roo Code <[email protected]> * Move auto-approval from `ChatView` to `Task` (RooCodeInc#9157) * feat(i18n): add internationalization for unexpected API response error message * fix(task): use consistent error message for API response failures and ensure message queue is never undefined * test: update vscode mock and improve test coverage * fix: Model switch re-applies selected profile (sync task.apiConfiguration) (RooCodeInc#9179) (RooCodeInc#9181) * Add custom Button component with variant system (RooCodeInc#9150) Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> Co-authored-by: Roo Code <[email protected]> * Changeset version bump (RooCodeInc#9154) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Matt Rubens <[email protected]> * feat(core): detect API configuration changes for model switching * fix: include mcpServers in getState() for auto-approval (RooCodeInc#9199) * fix: replace rate-limited badges with badgen.net (RooCodeInc#9200) * Batch settings updates from the webview to the extension host (RooCodeInc#9165) Co-authored-by: Roo Code <[email protected]> * fix: Apply updated API profile settings when provider/model unchanged (RooCodeInc#9208) (RooCodeInc#9210) fix: apply updated API profile settings when provider/model unchanged (RooCodeInc#9208) * fix: migrate Issue Fixer to REST + ProjectsV2 (RooCodeInc#9207) * fix(issue-fixer): migrate to REST for issue/comments and add ProjectsV2; remove Projects Classic mentions * Update .roo/rules-issue-fixer/4_github_cli_usage.xml Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> * Update .roo/rules-issue-fixer/4_github_cli_usage.xml Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> --------- Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> * Migrate conversation continuity to plugin-side encrypted reasoning items (Responses API) (RooCodeInc#9203) * Migrate conversation continuity to plugin-side encrypted reasoning items (Responses API) Summary We moved continuity off OpenAI servers and now maintain conversation state locally by persisting and replaying encrypted reasoning items. Requests are stateless (store=false) while retaining the performance/caching benefits of the Responses API. Why This aligns with how Roo manages context and simplifies our Responses API implementation while keeping all the benefits of continuity, caching, and latency improvements. What changed - All OpenAI models now use the Responses API; system instructions are passed via the top-level instructions field; requests include store=false and include=["reasoning.encrypted_content"]. - We persist encrypted reasoning items (type: "reasoning", encrypted_content, optional id) into API history and replay them on subsequent turns. - Reasoning summaries default to summary: "auto" when supported; text.verbosity only when supported. - Atomic persistence via safeWriteJson. Removed - previous_response_id flows, suppressPreviousResponseId/skipPrevResponseIdOnce, persistGpt5Metadata(), and GPT‑5 response ID metadata in UI messages. Kept - taskId and mode metadata for cross-provider features. Result - ZDR-friendly, stateless continuity with equal or better performance and a simpler codepath. * fix(webview): remove unused metadata prop from ReasoningBlock render * Responses API: retain response id for troubleshooting (not continuity) Continuity is stateless via encrypted reasoning items that we persist and replay. We now capture the top-level response id in OpenAiNativeHandler and persist the assistant message id into api_conversation_history.json solely for debugging/correlation with provider logs; it is not used for continuity or control flow. Also: silence request-body debug logging to avoid leaking prompts. * remove DEPRECATED tests * chore: remove unused Task types file to satisfy knip CI * fix(task): properly type cleanConversationHistory and createMessage args in Task to address Dan's review * chore: add changeset for v3.31.2 (RooCodeInc#9216) * Changeset version bump (RooCodeInc#9217) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Matt Rubens <[email protected]> * rename: sliding-window -> context-management; truncateConversationIfNeeded -> manageContext (RooCodeInc#9206) * Fix: Roo Anthropic input token normalization (avoid double-count) (RooCodeInc#9224) * OpenAI Native: gate encrypted_content include; remove gpt-5-chat-latest verbosity flag (fixes RooCodeInc#9225) (RooCodeInc#9231) openai-native: include reasoning.encrypted_content only when reasoningEffort is set; prevent Responses API error on non-reasoning models. types: remove supportsVerbosity from gpt-5-chat-latest to avoid invalid verbosity error. Fixes RooCodeInc#9225 * docs: remove Contributors section from README files (RooCodeInc#9198) Co-authored-by: Roo Code <[email protected]> * Release v3.31.3 (RooCodeInc#9232) * Changeset version bump (RooCodeInc#9233) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Matt Rubens <[email protected]> * Add native tool call support (RooCodeInc#9159) Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Consistently use Package.name for better support of the nightly app (RooCodeInc#9240) * fix: resolve 400 error with native tools on OpenRouter (RooCodeInc#9238) * fix: change tool_choice from required to auto for native protocol (RooCodeInc#9242) * docs: include PR numbers in release guide (RooCodeInc#9236) * Add enum support to configuration schema (
Problem
Dynamic MCP tools (with names like
mcp_serverName_toolName) were being converted touse_mcp_toolin the API conversation history in native mode. This caused the model to mistakenly thinkuse_mcp_toolis a valid tool to call directly, leading to confusion in future turns.Solution
Introduced a new
McpToolUsetype to handle native mode MCP tool calls separately from the XML modeuse_mcp_toolwrapper:McpToolUsewhich preserves the original tool name (mcp_serverName_toolName) in API historyuse_mcp_toolwrapper (unchanged behavior)Changes
McpToolUsetype insrc/shared/tools.tsto represent native MCP tool calls with preserved original nameNativeToolCallParserinsrc/core/assistant-message/NativeToolCallParser.tsto returnMcpToolUseinstead of converting touse_mcp_toolAssistantMessageContenttype insrc/core/assistant-message/parseAssistantMessage.tsto includeMcpToolUsemcp_tool_usehandling insrc/core/assistant-message/presentAssistantMessage.tsto execute MCP tools while preserving original namesTask.tsinsrc/core/task/Task.tsto storeMcpToolUsewith original tool names in API historyAdditional Changes
This PR also includes:
accessMcpResourceToolto extendBaseToolclassaccess_mcp_resourceas a native toolTesting
Important
Introduces
McpToolUsetype to preserve dynamic MCP tool names in native mode API history and refactorsaccessMcpResourceToolto extendBaseTool.McpToolUsetype intools.tsto preserve dynamic MCP tool names in native mode API history.NativeToolCallParserinNativeToolCallParser.tsto handleMcpToolUseinstead of converting touse_mcp_tool.AssistantMessageContenttype inparseAssistantMessage.tsto includeMcpToolUse.Task.tsto storeMcpToolUsewith original tool names in API history.accessMcpResourceToolto extendBaseToolclass inaccessMcpResourceTool.ts.access_mcp_resourceas a native tool inaccess_mcp_resource.tsandindex.ts.askFollowupQuestionTool.spec.tsandvalidateToolUse.spec.tsto cover new MCP tool handling.This description was created by
for 626791e. You can customize this summary. It will automatically update as commits are pushed.