Skip to content

fix(runtime): preserve provider apiStyle for foreign catalog models - #1314

Merged
vastsa merged 2 commits into
vastsa:mainfrom
Totopo27:fix/openai-compatible-gemini-relay
Oct 2, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
Totopo27:fix/openai-compatible-gemini-relay

Conversation

@Totopo27

@Totopo27 Totopo27 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Observable Behavior Changes

  • Preserve provider wire protocol for OpenAI-compatible relays: When configuring OpenAI-compatible providers (such as EasyCLIProxyAPI or Cliproxy) with models whose names match first-party catalog publishers (e.g. gemini-3.8-flash or claude-sonnet-4-6), providerRequestTransport now checks wire compatibility before letting the catalog api override provider.apiStyle.
  • Foreign protocols like google-generative-ai or anthropic-messages no longer overwrite an OpenAI provider's chat_completions wire style, eliminating the HTTP 404 errors caused by dispatching Google Generative AI requests to OpenAI-compatible endpoints.
  • Within the OpenAI family, model-level pins (such as responses-only models under OpenCode Go, issue [Bug] opencode_go provider 强制走 completions,导致 muse-spark 稳定 500 #105) continue to be honored as intended.

Main Files Modified

  • packages/agent-runtime/src/provider-binding.ts: Check compatibility between model-level api and provider apiStyle before applying the override.
  • packages/agent-runtime/src/provider-binding.test.ts: Added regression tests verifying that OpenAI completions are preserved for Gemini and Claude models configured on relay endpoints.
  • docs/spec/03-runtime/11-provider-model-system.md (and docs/zh-CN/ equivalent): Documented foreign-family catalog wire override restrictions.

Verification

  • pnpm --filter @pi-desktop/agent-runtime test src/provider-binding.test.ts: Passed (39 tests).
  • pnpm --filter @pi-desktop/shared test: Passed (94 suites, 1158 tests).
  • pnpm --filter @pi-desktop/desktop typecheck: Passed.
  • pnpm lint: Passed.
  • cargo fmt --check: Passed.
  • cargo clippy -p host-core --all-targets: Passed.
  • pnpm check:agent-policy & pnpm check:pr-base: Passed.

Fixes #1310

When an OpenAI-compatible provider configures a canonical model name
such as gemini-3.8-flash, relay catalog resolution matches the official
Google model entry and attaches api: "google-generative-ai" to its
modelConfig. Previously, providerRequestTransport allowed any model-level
api to override the provider apiStyle unconditionally, forcing the runtime
to route requests through the Google Generative AI adapter against the
OpenAI proxy endpoint, causing immediate HTTP 404 errors.

Scope model-level wire API overrides to wire-compatible protocols,
ensuring that foreign catalog protocols (e.g. Google Generative AI or
Anthropic Messages) do not overwrite an OpenAI-compatible provider's
configured chat_completions transport.

fixes vastsa#1310
@vastsa

vastsa commented Oct 2, 2026

Copy link
Copy Markdown
Owner

thank you!

@vastsa
vastsa merged commit bd38e84 into vastsa:main Oct 2, 2026
4 checks passed
@vastsa

vastsa commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Thanks for the focused fix. PR #1314 was merged into main with your commit preserved. The follow-up updates E2E-005E to cover the Gemini catalog API case alongside the existing compatible model-level override scenario.

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] 所有 Gemini 模型均无法使用,返回 404,而 其他模型正常

2 participants