jcode icon indicating copy to clipboard operation
jcode copied to clipboard

fix(provider): do not report OpenAI-compatible transport as native OpenRouter

Open Helweg opened this issue 3 months ago • 2 comments

Problem

Jcode uses a shared transport slot for native OpenRouter and OpenAI-compatible endpoints. When native OpenAI credentials are present, runtime activation can leave an OpenRouter transport marker behind. Status and route-summary reporting then incorrectly describe OpenRouter as configured even though no OPENROUTER_API_KEY exists.

This is distinct from #691: that issue concerns named-profile identity, while this is a false native-OpenRouter availability report caused by shared transport state.

Expected behavior

  • Native OpenAI or direct OpenAI-compatible credentials must not make OpenRouter appear configured.
  • Native OpenRouter remains reported only when it is genuinely configured.
  • Direct compatible routes must continue to work and retain their placeholder behavior.

Fix

Proposed implementation:

  1. Make has_openrouter_credentials() confirm the configured endpoint has native OpenRouter features, not merely a shared transport marker.
  2. Classify native OpenRouter in route summaries using runtime provider-routing support, avoiding process-global transport-state contamination.
  3. Add regressions for native OpenAI credentials, direct-compatible transport overrides, genuine OpenRouter credentials, auth status, and route placeholder behavior.

Likely affected files:

  • crates/jcode-base/src/provider/openrouter.rs
  • crates/jcode-base/src/provider/catalog_routes.rs
  • crates/jcode-base/src/auth/tests.rs

Validation

Focused tests passed for:

  • native OpenAI credentials not reporting OpenRouter
  • direct-compatible transport overrides
  • native OpenRouter credentials still reporting correctly
  • fast auth status
  • route placeholder filtering

On the affected local configuration, auth-test --all-configured now reports OpenAI and OpenCode Go only, with no OpenRouter entry.

Helweg avatar Aug 05 '26 07:08 Helweg

@1jehuang the fix/custom_openai_compatible branch adds per-provider display_name for custom OpenAI-compatible profiles so the runtime identity is correctly surfaced, which addresses the transport-reporting confusion described here. It has been rebased onto the latest master and validated. Would be great if you could take a look.

alecuba16 avatar Aug 07 '26 06:08 alecuba16

Implemented an independent fix in PR #863. Native OpenRouter credential reporting now requires native OpenRouter provider features, while direct compatible transport behavior remains available. Focused auth and route regressions pass.

--- — Jcode agent (automated triage), on behalf of @1jehuang

1jehuang avatar Aug 09 '26 21:08 1jehuang