Repository navigation
fix(model): route OpenCode Go models to their published endpoint - #708
Merged
Merged
Conversation
OpenCode Go serves some models on the Anthropic Messages API or the Responses API instead of chat/completions, but Forge picked the wire protocol per provider profile. union-alpha and the MiniMax/Qwen models on /messages were posted to chat/completions and rejected upstream. Map the documented Go endpoints by model id, share the Anthropic Messages path with Bearer + x-opencode-session auth, and cover grok-4.6/gpt-5.6-luna on /responses.
mohitranka
force-pushed
the
forge/check-opencode-go-union
branch
from
September 16, 2026 17:14
777f94b to
48e339e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
opencode-go/union-alpha(and every other Go model served on/messages) fails in Forge with an upstream error, while the same model works in OpenCode. It is listed byGET https://opencode.ai/zen/go/v1/models, so it is selectable.Root cause
Forge picks the wire protocol per provider profile, not per model (
opencode_goisProviderTransport::OpenaiCompat), so everyopencode-go/*request is POSTed to{base}/chat/completions. OpenCode Go documents a different endpoint per model — union-alpha, MiniMax, and Qwen live on the Anthropic Messages API (/v1/messages), Grok 4.6 and GPT 5.6 Luna on/responses. The/modelslisting carries no protocol metadata, so the endpoint has to be mapped by model id.Changes
crates/forge-model/src/native/openai.rs: add the documented Go endpoint map; route/messagesmodels through the Anthropic path and extend the Responses set togrok-4.6/gpt-5.6-luna. Unlisted ids keep chat/completions.crates/forge-model/src/native/anthropic.rs: extract a sharedcomplete_messages. It takes aMessagesAuth— Anthropic'sx-api-key+ beta header, or OpenCode'sAuthorization: Bearer+x-opencode-session+forge/<version>user agent. Model ids are stripped of the provider prefix generically (wire_model_id) instead of onlyanthropic/.README.md: note that OpenCode Go spans three protocols and Forge selects the published endpoint per model.Tests
sends_union_alpha_to_opencode_go_messages— assertsPOST /v1/messages,union-alphaon the wire, Bearer auth, session header, and nox-api-key.sends_grok_to_opencode_go_responses— the newly mapped Responses models on the Go route.opencode_go_models_map_to_their_endpoint— table guard, including thatopencode-zen/union-alphais untouched.cargo fmt --all -- --check,cargo clippy --package forge-model --all-targets --locked -- -D warnings,cargo test --package forge-model --locked native::(50 passed), andanthropic::(9 passed) all pass locally.Follow-up
Ids present in the catalog but absent from OpenCode's published endpoint table (
omen-alpha,qwen3.5-plus,hy3-preview,deepseek-flash,mimo-v2-omni,grok-4.5,glm-5,kimi-k2.5) intentionally stay on chat/completions until their endpoint is confirmed.