Skip to content

fix(model): route OpenCode Go models to their published endpoint - #708

Merged
mohitranka merged 1 commit into
mainfrom
forge/check-opencode-go-union
Sep 16, 2026
Merged

mohitranka merged 1 commit into
mainfrom
forge/check-opencode-go-union

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

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 by GET 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_go is ProviderTransport::OpenaiCompat), so every opencode-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 /models listing 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 /messages models through the Anthropic path and extend the Responses set to grok-4.6 / gpt-5.6-luna. Unlisted ids keep chat/completions.
  • crates/forge-model/src/native/anthropic.rs: extract a shared complete_messages. It takes a MessagesAuth — Anthropic's x-api-key + beta header, or OpenCode's Authorization: Bearer + x-opencode-session + forge/<version> user agent. Model ids are stripped of the provider prefix generically (wire_model_id) instead of only anthropic/.
  • 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 — asserts POST /v1/messages, union-alpha on the wire, Bearer auth, session header, and no x-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 that opencode-zen/union-alpha is untouched.

cargo fmt --all -- --check, cargo clippy --package forge-model --all-targets --locked -- -D warnings, cargo test --package forge-model --locked native:: (50 passed), and anthropic:: (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.

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
mohitranka force-pushed the forge/check-opencode-go-union branch from 777f94b to 48e339e Compare September 16, 2026 17:14
@mohitranka
mohitranka merged commit c728270 into main Sep 16, 2026
3 checks passed
@mohitranka
mohitranka deleted the forge/check-opencode-go-union branch September 16, 2026 17:18
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