fix: route OpenCode Go requests to correct endpoint instead of Zen#2899
Merged
amitksingh1490 merged 2 commits intomainfrom Apr 9, 2026
Merged
fix: route OpenCode Go requests to correct endpoint instead of Zen#2899amitksingh1490 merged 2 commits intomainfrom
amitksingh1490 merged 2 commits intomainfrom
Conversation
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>
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.
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_zenandopencode_goproviders shareresponse_type: "OpenCode", which routes them through the sameOpenCodeZenResponseRepository. Thebuild_providermethod hardcoded all endpoint URLs tohttps://opencode.ai/zen/...paths. When a user selected OpenCode Go (which should usehttps://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:
opencode_go+ model (e.g.glm-5)https://opencode.ai/zen/go/v1/chat/completionsProviderRoutermatchesOpenCoderesponse type, delegates toOpenCodeZenResponseRepositorybuild_provider()overwrites URL tohttps://opencode.ai/zen/v1/chat/completionsChanges
/v1/chat/completionssuffix) sobuild_providercan append the correct backend-specific pathopencode_zen.rs): Updatedbuild_providerto derive endpoint URLs from the provider's configured base URL instead of hardcoding themKey Implementation Details
build_providernow 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:https://opencode.ai/zen+/v1/chat/completions(correct)https://opencode.ai/zen/go+/v1/chat/completions(now correct)Testing
cargo test -p forge_repo opencode