Skip to content

fix: force tool parameter passthrough for OpenRouter models#11970

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/openrouter-require-tools-params
Draft

fix: force tool parameter passthrough for OpenRouter models#11970
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/openrouter-require-tools-params

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 21, 2026

Related GitHub Issue

Closes: #11968

Description

This PR attempts to address Issue #11968 where Nemotron 3 Super 120b-a12b (and potentially other models) produce broken output when used through OpenRouter.

Root cause: When OpenRouter's metadata does not list tools in a model's supported_parameters, OpenRouter may either strip the tool parameters or apply prompt-based transforms that produce poor results (e.g. wrapping output in [{code here}] formatting). This happens even for models like Nemotron 3 Super that actually support native tool calling.

Fix: Added require_parameters: ["tools", "tool_choice"] to the OpenRouter provider configuration in createMessage. This tells OpenRouter to always pass tool-calling parameters through to the underlying model, regardless of what the model's metadata says about supported parameters. This is done via the OpenRouter provider routing API.

Key changes:

  • Added provider field to OpenRouterChatCompletionParams type
  • Always include provider.require_parameters: ["tools", "tool_choice"] in createMessage requests
  • When a specific provider is configured, the routing config (order, only, allow_fallbacks) is merged with require_parameters

Feedback and guidance are welcome.

Test Procedure

  • Added 2 new unit tests verifying require_parameters is always present in the provider config
  • Added test verifying require_parameters merges correctly with specific provider routing
  • All 26 existing OpenRouter handler tests continue to pass
  • Run: cd src && npx vitest run api/providers/__tests__/openrouter.spec.ts

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Interactively review PR in Roo Code Cloud

When OpenRouter metadata does not list "tools" in supported_parameters
for a model, OpenRouter may strip tool parameters or apply prompt-based
transforms that produce poor results. This affects models like Nemotron
3 Super 120b-a12b that actually support native tool calling.

By adding require_parameters: ["tools", "tool_choice"] to the provider
config, we tell OpenRouter to always pass these parameters through to
the model regardless of its metadata.

Fixes #11968
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.

[BUG] Can't Code: Nemotron 3 Super 120b-a12b Open Router

1 participant