openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

OpenRouter tool-incapable model surfaces misleading Responses API invalid_union error

Open oxoxDev opened this issue 5 months ago • 1 comments

Summary

A BYO OpenRouter user whose selected model has no tool-capable endpoint hits a confusing openrouter Responses API error: … invalid_union instead of OpenRouter's real, actionable error — and the app wastes a guaranteed-to-fail /v1/responses round-trip on every such request.

Problem

What happens: When an OpenRouter model is selected whose providers don't support tool use (e.g. nvidia/nemotron-3.5-content-safety:free), OpenHuman sends chat/completions with agent tools. OpenRouter replies:

404 Not Found: {"error":{"message":"No endpoints found that support tool use. Try disabling \"spawn_async_subagent\". To learn more about provider routing, visit https://openrouter.ai/docs/guides/routing/provider-s…"}}

OpenRouter is a builtin cloud provider built with supports_responses_fallback = true (the AuthStyle::Bearer arm in provider/factory.rs constructs via OpenAiCompatibleProvider::new). So the 404 triggers the /v1/responses fallback. But OpenRouter's /v1/responses rejects OpenHuman's ResponsesRequest body schema:

400: {"error":{"code":"invalid_prompt","message":"Invalid Responses API request"},"metadata":{"raw":"[{"code":"invalid_union", …}]"}}

Impact:

  • The user sees a misleading Responses API / invalid_union error that hides the real cause (their model can't do tool use).
  • A guaranteed-fail second request is issued on every occurrence.
  • Sentry TAURI-RUST-863 (~3.1k events / 19 users) is pure noise from the doomed fallback.

Repro:

  1. Configure an OpenRouter BYO key.
  2. Select a model whose providers don't support tool calling (e.g. a content-safety / moderation model).
  3. Run any agent turn that sends tools.
  4. Observe openrouter Responses API error … invalid_union instead of the OpenRouter 404 No endpoints found….

Version / platform: desktop, observed across 0.57.11–0.57.53 (macOS; provider-agnostic).

Solution

OpenRouter does not implement the OpenAI Responses API (it rejects the request body with invalid_union), so the /v1/responses fallback is always wrong for it. Build the OpenRouter provider with new_no_responses_fallback (keyed via is_openrouter_provider), exactly as Ollama / LM Studio were keyed in TAURI-RUST-59Y. The genuine, actionable OpenRouter 404 then surfaces to the user instead of the misleading Responses error, and the wasted round-trip is removed.

Acceptance criteria

  • [ ] Repro gone — OpenRouter no longer issues a /v1/responses fallback on a chat/completions 404; user sees the real OpenRouter error.
  • [ ] Regression safety — unit test asserting OpenRouter does not fall back to /responses on 404 (mirror of the 59Y Ollama/LM Studio guards); generic-cloud fallback test stays green.
  • [ ] Diff coverage ≥ 80%.

Related

  • Sentry: TAURI-RUST-863 (~3.1k ev / 19 users) — the doomed /responses fallback noise this fixes.
  • Sentry: TAURI-RUST-ADC (~5.9k ev / 10 users) — the same root cause surfacing as the genuine 404 No endpoints found that support tool use. This is preventable user-state (an agent that needs tools was routed to a non-tool-capable model). It should get a real prevention fix (tool-capability gating / model validation), not a classifier demotion. Tracked here as follow-up so it is not buried.
  • Precedent: TAURI-RUST-59Y (Ollama / LM Studio — same guaranteed-404 /responses fallback class).

oxoxDev avatar Jun 23 '26 12:06 oxoxDev

Fixed by #4009 (provider-capability gate) rather than the openrouter-only PR #4010 (closed as superseded). #4009 disables the doomed /v1/responses fallback for OpenRouter along with every other chat-completions-only builtin. The TAURI-RUST-ADC prevention follow-up (tool-capability gating, not demotion) is captured in #4009.

oxoxDev avatar Jun 23 '26 18:06 oxoxDev