Skip to content

fix(decopilot): allow direct tool calls in gateway modes with activeT…#2502

Merged
pedrofrxncx merged 1 commit intomainfrom
fix/decopilot-gateway-mode-tool-discovery
Feb 26, 2026
Merged

fix(decopilot): allow direct tool calls in gateway modes with activeT…#2502
pedrofrxncx merged 1 commit intomainfrom
fix/decopilot-gateway-mode-tool-discovery

Conversation

@pedrofrxncx
Copy link
Collaborator

@pedrofrxncx pedrofrxncx commented Feb 26, 2026

Summary

  • Always create a passthrough client (all real tools) in decopilot mode
  • In smart_tool_selection and code_execution modes, also create a strategy client for gateway meta-tools
  • Register both tool sets with streamText but filter visibility via activeTools
  • Prevents AI SDK errors when the model discovers a tool and tries to call it directly

Motivation

Previously, when the model used smart tool selection or code execution mode and discovered a tool (e.g., XPTO) via GATEWAY_SEARCH_TOOLS, it would sometimes attempt to call XPTO directly instead of routing through GATEWAY_CALL_TOOL. Since XPTO was not registered as a tool in streamText, the AI SDK would throw an error.

Implementation

The approach uses AI SDK's activeTools field: tools exist and are callable, but their schemas are not shown to the LLM, allowing direct calls without errors while maintaining the intended gateway routing pattern.

Testing

  • Test smart_tool_selection mode: verify model uses GATEWAY_CALL_TOOL, not direct calls
  • Test code_execution mode: verify model uses GATEWAY_RUN_CODE, not direct calls
  • Test passthrough mode: verify behavior unchanged (all tools visible)
  • Verify tool execution still works end-to-end when model bypasses gateway (fallback path)

Notes

  • Two lazy client instances created per request in gateway modes (minimal overhead due to lazy connection pattern)
  • Could be optimized to share underlying connection pool in future if needed

Summary by cubic

Fixes tool discovery errors in decopilot gateway modes. Registers all real tools and hides them with activeTools so direct tool calls work without SDK errors, while keeping gateway routing.

  • Bug Fixes
    • Always create a passthrough client with all real tools and use it for server instructions.
    • In smart_tool_selection and code_execution, also create a strategy client for gateway meta-tools.
    • Register passthrough + strategy + built-in tools; expose only strategy + built-ins via activeTools (strategy overrides passthrough, built-ins override both).
    • Close model, passthrough, and strategy clients on abort.
    • Passthrough mode behavior unchanged.

Written for commit 96b21f8. Summary will update on new commits.

…ools filtering

Always create a passthrough client to expose all real tools. In smart_tool_selection
and code_execution modes, also create a strategy client for gateway meta-tools.
Register all tools with streamText but use activeTools to hide passthrough tools from
the LLM. This prevents AI SDK errors when the model attempts to directly call a
discovered tool instead of routing through GATEWAY_CALL_TOOL.
@github-actions
Copy link
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

Release Options

Should a new version be published when this PR is merged?

React with an emoji to vote on the release type:

Reaction Type Next Version
👍 Prerelease 2.115.1-alpha.1
🎉 Patch 2.115.1
❤️ Minor 2.116.0
🚀 Major 3.0.0

Current version: 2.115.0

Deployment

  • Deploy to production (triggers ArgoCD sync after Docker image is published)

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@pedrofrxncx pedrofrxncx merged commit 117f07b into main Feb 26, 2026
8 checks passed
@pedrofrxncx pedrofrxncx deleted the fix/decopilot-gateway-mode-tool-discovery branch February 26, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant