Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Nov 25, 2025

Problem

Dynamic MCP tools (with names like mcp_serverName_toolName) were being converted to use_mcp_tool in the API conversation history in native mode. This caused the model to mistakenly think use_mcp_tool is a valid tool to call directly, leading to confusion in future turns.

Solution

Introduced a new McpToolUse type to handle native mode MCP tool calls separately from the XML mode use_mcp_tool wrapper:

  • Native mode: MCP tools are now represented as McpToolUse which preserves the original tool name (mcp_serverName_toolName) in API history
  • XML mode: Continues using use_mcp_tool wrapper (unchanged behavior)

Changes

  1. Added McpToolUse type in src/shared/tools.ts to represent native MCP tool calls with preserved original name
  2. Updated NativeToolCallParser in src/core/assistant-message/NativeToolCallParser.ts to return McpToolUse instead of converting to use_mcp_tool
  3. Updated AssistantMessageContent type in src/core/assistant-message/parseAssistantMessage.ts to include McpToolUse
  4. Added mcp_tool_use handling in src/core/assistant-message/presentAssistantMessage.ts to execute MCP tools while preserving original names
  5. Updated Task.ts in src/core/task/Task.ts to store McpToolUse with original tool names in API history

Additional Changes

This PR also includes:

  • Refactored accessMcpResourceTool to extend BaseTool class
  • Added access_mcp_resource as a native tool
  • Updated MCP servers section to provide protocol-specific instructions

Testing

  • ✅ All existing tests pass (4216 passed)
  • ✅ TypeScript compilation successful
  • ✅ Linting passed

Important

Introduces McpToolUse type to preserve dynamic MCP tool names in native mode API history and refactors accessMcpResourceTool to extend BaseTool.

  • Behavior:
    • Introduces McpToolUse type in tools.ts to preserve dynamic MCP tool names in native mode API history.
    • Updates NativeToolCallParser in NativeToolCallParser.ts to handle McpToolUse instead of converting to use_mcp_tool.
    • Updates AssistantMessageContent type in parseAssistantMessage.ts to include McpToolUse.
    • Updates Task.ts to store McpToolUse with original tool names in API history.
  • Tools:
    • Refactors accessMcpResourceTool to extend BaseTool class in accessMcpResourceTool.ts.
    • Adds access_mcp_resource as a native tool in access_mcp_resource.ts and index.ts.
  • Testing:
    • Updates tests in askFollowupQuestionTool.spec.ts and validateToolUse.spec.ts to cover new MCP tool handling.

This description was created by Ellipsis for 626791e. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 25, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 25, 2025

Rooviewer Clock   See task on Roo Cloud

Re-review completed. All previously identified issues have been resolved.

  • Missing parser case for access_mcp_resource in NativeToolCallParser - tool falls back to legacy string-based parsing instead of using typed native arguments
Previous reviews

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

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 25, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 25, 2025
@daniel-lxs daniel-lxs force-pushed the fix/native-mcp-tool-history branch from 18a62b6 to bfecce5 Compare November 25, 2025 04:33
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Nov 25, 2025
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
@daniel-lxs daniel-lxs force-pushed the fix/native-mcp-tool-history branch from 652f19a to 626791e Compare November 25, 2025 16:39
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 25, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Nov 25, 2025
@mrubens mrubens merged commit 774b492 into main Nov 25, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 25, 2025
@mrubens mrubens deleted the fix/native-mcp-tool-history branch November 25, 2025 18:16
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 (