Skip to content

fix: resolve model-specific OpenCode inference routes - #71

Merged
grikomsn merged 2 commits into
mainfrom
codex/fix-model-gateway-resolution
Oct 15, 2026
Merged

grikomsn merged 2 commits into
mainfrom
codex/fix-model-gateway-resolution

Conversation

@grikomsn

@grikomsn grikomsn commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Gemini models on Go can resolve to the Google protocol while retaining a generic gateway base. The legacy /zen/go/v1 gateway has no Google route, so requests return an HTML 404. Console Google requests also need the /models/<id> path segment.

Resolve generic OpenCode bases to canonical protocol-specific /inference routes for Chat Completions, Responses, Messages, and Google. Following the neighboring Copilot providers' convention, derive the Console server, discovery URLs, and inference URLs from shared origin/base constants and a protocol-path table. Discovery now uses canonical /inference endpoints; cached /zen descriptors remain supported. Preserve custom and explicit protocol endpoints, and use the Gemini fallback on both gateways when metadata is missing or unavailable.

Keep the MiniMax mode condition: a live minimax-m3 check returned 200 through Chat Completions on Console and ModelProtocolUnsupported through Messages. Go accepted both formats, and its model metadata selects Messages. Regression tests cover the distinct defaults and explicit SDK overrides.

Related: grikomsn/pi-provider-opencode-console#21. The original pi fix was merged in grikomsn/pi-provider-opencode-console#22. Upstream references: inference API and legacy gateway routing.

Validation:

  • npm run package: all 189 tests passed, followed by successful VSIX packaging.
  • Verified live canonical Console/Go discovery and MiniMax protocol behavior.
  • Sideloaded the updated VSIX into stable VS Code and verified the installed transport JavaScript matches the tested build. Manual Copilot Chat testing can proceed after reloading the window.
  • Includes updated routing documentation and a patch Changeset.

DevJake pushed a commit to grikomsn/pi-provider-opencode-console that referenced this pull request Oct 15, 2026
Go discovers `gemini-4-argon-contributor` with the Google SDK, but the
generic `/zen/go/v1` base has no Google route. Selecting the right SDK
alone still produces an HTML 404.

Resolve generic OpenCode bases to canonical protocol-specific
`/inference` routes before SDK URL composition. Keep model-level SDK
metadata authoritative, add the Gemini fallback on both gateways, and
align the `qwen3.8-max` fallback with its Messages protocol on Go and
Chat Completions protocol on Console. Custom and explicit protocol
endpoints retain their existing SDK normalization.

Honor `PI_CODING_AGENT_DIR` for session storage so isolated pi runs use
the same credential directory as the host. Add routing, discovery,
Google streaming, and storage regressions, update the README, and
include a patch Changeset.

Fixes #21. Companion VS Code fix:
grikomsn/opencode-copilot-chat#71. Upstream
references: [inference
API](https://opencode.ai/v2/docs/console/inference/) and [legacy gateway
routing](https://github.com/anomalyco/opencode/blob/dev/packages/console/app/src/lib/inference-proxy.ts).

Validation:
- `npm run check`: typecheck and all 119 tests passed; the routing
regressions failed before the fix.
- `npm run package`: package dry run passed.
- Isolated pi 1.2.0 with only this extension, separate agent state, no
tools/MCP/context files, and ephemeral credentials: `qwen3.8-max`
returned `ROUTE_OK` through Messages.
- The same isolated Gemini request now reaches the inference API and
returns a structured privacy-policy error because the workspace
disallows endpoints that train on request data. Successful Gemini
generation remains unverified under that policy; no privacy setting was
changed.
- Verified normal pi credentials were unchanged and removed temporary
credentials after each run.
@grikomsn
grikomsn merged commit c4b5352 into main Oct 15, 2026
3 checks passed
grikomsn added a commit to grikomsn/pi-provider-opencode-console that referenced this pull request Oct 15, 2026
Discovery still uses the legacy `/zen` URLs after #22, and protocol URL
construction repeats the OpenCode origin. Derive the Console server,
catalog bases, and inference URLs from shared origin/base constants and
a protocol-path table, following the neighboring Copilot providers'
convention. Public discovery now uses `/inference/v1/models` and
`/inference/go/v1/models`; legacy gateway bases in cached descriptors
remain supported.

Keep MiniMax's gateway-specific fallback. A live `minimax-m3` check
returned 200 for Chat Completions on Console and
`ModelProtocolUnsupported` for Messages. Go accepted both formats, and
its metadata selects Messages. Explicit SDK metadata continues to take
precedence over family fallbacks.

Follow-up to merged #22; this branch starts from its merge commit and
contains only the endpoint-constant cleanup, updated tests/docs, and a
new patch Changeset. Companion VS Code change:
grikomsn/opencode-copilot-chat#71.

Validation:
- `npm run check`: typecheck and all 120 tests passed.
- `npm run package`: package dry run passed.
- Canonical Console and Go catalog endpoints returned 200; the legacy
bases remain covered by routing tests.
- Isolated pi 1.2.0 discovered models through canonical Go discovery and
returned `ROUTE_OK` using `qwen3.8-max`. Normal pi credentials were
unchanged, and temporary credentials were removed.
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