Skip to content

fix: route OpenCode Go requests to correct endpoint instead of Zen#2899

Merged
amitksingh1490 merged 2 commits intomainfrom
fix/opencode-go-url-routing
Apr 9, 2026
Merged

fix: route OpenCode Go requests to correct endpoint instead of Zen#2899
amitksingh1490 merged 2 commits intomainfrom
fix/opencode-go-url-routing

Conversation

@amitksingh1490
Copy link
Copy Markdown
Contributor

Summary

Fix OpenCode Go requests being incorrectly routed to the OpenCode Zen endpoint due to hardcoded URLs in the provider routing layer.

Context

Both opencode_zen and opencode_go providers share response_type: "OpenCode", which routes them through the same OpenCodeZenResponseRepository. The build_provider method hardcoded all endpoint URLs to https://opencode.ai/zen/... paths. When a user selected OpenCode Go (which should use https://opencode.ai/zen/go/...), the hardcoded URL overwrote the correct Go base path, causing all requests to hit the Zen endpoint instead.

Request flow before fix:

  1. User selects opencode_go + model (e.g. glm-5)
  2. Provider URL = https://opencode.ai/zen/go/v1/chat/completions
  3. ProviderRouter matches OpenCode response type, delegates to OpenCodeZenResponseRepository
  4. build_provider() overwrites URL to https://opencode.ai/zen/v1/chat/completions
  5. Request sent to Zen endpoint instead of Go

Changes

  • provider.json: Changed both OpenCode Zen and Go URLs to base URLs (without /v1/chat/completions suffix) so build_provider can append the correct backend-specific path
  • opencode.rs (renamed from opencode_zen.rs): Updated build_provider to derive endpoint URLs from the provider's configured base URL instead of hardcoding them
  • mod.rs / chat.rs: Updated module references for the rename

Key Implementation Details

build_provider now reads the provider's base URL and appends the appropriate API path based on the model's backend type (/v1/chat/completions, /v1/messages, /v1/responses, /v1). This means:

  • Zen provider: https://opencode.ai/zen + /v1/chat/completions (correct)
  • Go provider: https://opencode.ai/zen/go + /v1/chat/completions (now correct)

Testing

cargo test -p forge_repo opencode

Both opencode_zen and opencode_go shared response_type 'OpenCode', routing
through OpenCodeZenResponseRepository. The build_provider method hardcoded
all URLs to https://opencode.ai/zen/... paths, causing OpenCode Go requests
(which should use https://opencode.ai/zen/go/...) to be sent to the Zen
endpoint instead.

Fix by changing provider.json URLs to base URLs (without /v1/chat/completions
suffix) and having build_provider append backend-specific paths to the
provider's configured base URL. This preserves the correct base path for
both Zen and Go (and any future variants).

Also rename opencode_zen.rs to opencode.rs to reflect it serves all OpenCode
providers.

Co-Authored-By: ForgeCode <noreply@forgecode.dev>
@github-actions github-actions bot added type: fix Iterations on existing features or infrastructure. update: provider Updates provider.json configuration. labels Apr 9, 2026
@amitksingh1490 amitksingh1490 enabled auto-merge (squash) April 9, 2026 06:54
@amitksingh1490 amitksingh1490 merged commit bac727b into main Apr 9, 2026
9 checks passed
@amitksingh1490 amitksingh1490 deleted the fix/opencode-go-url-routing branch April 9, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure. update: provider Updates provider.json configuration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant