Skip to content

fix(runtime): preserve custom model identity in OpenCode config - #604

Open
Yevanchen wants to merge 1 commit into
mainfrom
fix/runtime-byok-model-identity
Open

Yevanchen wants to merge 1 commit into
mainfrom
fix/runtime-byok-model-identity

Conversation

@Yevanchen

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve custom endpoint model IDs, including slashes, and use the same resolved model ID for the LLM proxy grant and OpenCode configuration.
  • Render OpenCode's provider prefix only at the adapter boundary; remove the duplicate model parsing helpers.

Why

Selecting deepseek/deepseek-v4-flash through an openai-compatible credential previously produced an OpenCode selection of deepseek/deepseek-v4-flash, although only openai-compatible was enabled. OpenCode can then fall back to another declared model and receive a 403 because its request differs from the model authorized by the proxy.

The selection is now openai-compatible/deepseek/deepseek-v4-flash, while both the upstream model ID and grant retain deepseek/deepseek-v4-flash. Existing preset vendor-prefix normalization remains supported.

Verification

  • just test-file apps/api/tests/runtime-vendor-env-vars.test.ts: 33 passed; slash-containing regression cases failed before the fix and passed afterward.
  • just test-file apps/api/tests/driver-llm-proxy-route.test.ts: 34 passed, including admission of the provisioned model and rejection of altered models/protocols.
  • just tc-package @mosoo/api, just lint, changed-file formatting checks, and git diff --check: passed.
  • Manual: ran the pinned OpenCode 1.18.4 ACP process against a local controlled Chat Completions endpoint, with both gpt-5 and deepseek/deepseek-v4-flash declared. The old selection requested GPT and received a model-capability 403. The fixed selection requested DeepSeek throughout, executed a real bash tool writing pi-byok-ok to a temporary file, and completed the turn.
  • Full gate: just check was attempted on macOS; existing driver process-supervision tests require Linux /usr/bin/setsid and fail locally. See Linux CI for the complete gate.
  • Not run: production Sandbox / live upstream acceptance. The local reproduction proves this failure mechanism, but the original production request body was unavailable.

Impact

  • User/API/contract changes: custom model IDs remain intact, avoiding unintended model fallback and proxy denial. No public schema or UI changes.
  • Generated files / GraphQL / DB / lockfile: none.
  • Env or config changes: corrected generated OpenCode model selection; no new environment variables or secrets. No Pi dependency or runtime migration.
  • Risk and rollback: custom model IDs beginning with openai-compatible/ are now treated literally. Revert this commit to restore prior behavior. Deployment verification should use a new session/driver so it receives the new configuration and grant; existing generated session configuration is not rewritten.

Review

  • Closest review areas: OpenCode provider selection, opaque custom model IDs, and exact model/protocol proxy authorization.
  • Known trade-offs: retains the existing protocol selection and preset compatibility rules; this is a focused model-identity fix.

@Yevanchen
Yevanchen requested a review from samzong as a code owner September 6, 2026 17:37
@Yevanchen Yevanchen self-assigned this Sep 6, 2026
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