fix(setup): align custom provider base URL between wizard probe and chat client#3669
Merged
Merged
Conversation
…hat client The setup wizard accepts whatever base URL the user pastes and probes it with GET /models. The conversation-time client, however, concatenated "" + "/v1/messages" for Anthropic and "/chat/completions" for OpenAI against that same stored URL. For Anthropic providers the two paths could diverge: - User pastes "https://proxy.example.com" (root form): probe hits https://proxy.example.com/v1/models (no /v1 in base) chat client hits https://proxy.example.com/v1/messages (root + /v1) — aligned. - User pastes "https://proxy.example.com/v1" (OpenAI form): probe hits https://proxy.example.com/v1/v1/models (404) chat client hits https://proxy.example.com/v1/v1/messages (404) — silently broken. The fix has two parts: 1. Anthropic client (internal/provider/anthropic/anthropic.go): New() now strips a trailing /v1 from the stored base URL before storing the root, so +/v1/messages is correct for both shapes. 2. Wizard probe (internal/cli/cli.go): Two openai.FetchModels(ctx, baseURL+"/models", ...) call sites in the custom and Anthropic wizard flows are replaced with a new fetchModelListCompat helper that walks the full set of candidate URLs from config.BuildModelFetchURLs (root, /v1, known compat suffixes). Endpoint-miss on one URL falls through to the next; non-miss errors bubble up immediately. Tests: - TestBaseURLNormalizedForV1Messages (provider/anthropic): 6 table cases covering plain root, /v1, /v1/, /api/v1, trailing slash only, and empty (falls back to default). - TestFetchModelListCompatWalksCandidates (cli): 4 subtests using httptest — Anthropic root form falls through to /v1/models, versioned v1 base URL hits /v1/models directly, all-miss returns empty for manual fallback, connection refused bubbles up.
esengine
approved these changes
Jun 9, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Verified end-to-end. Traced that the Anthropic client posts to c.baseURL+"/v1/messages", so a base URL ending in /v1 produced /v1/v1/messages (404). Round-trip test against a mock server confirms: before the fix the request hits /v1/v1/messages, after it hits /v1/messages, and the default root is unaffected. anthropic + cli packages pass. The wizard probe now walking the same candidate URLs closes the gap with the chat client. Thanks.
SuMuxi66
pushed a commit
to SuMuxi66/DeepSeek-Reasonix
that referenced
this pull request
Jun 10, 2026
…hat client (esengine#3669) Wizard now probes the same candidate URLs (root + /v1 + compat suffixes) the chat client resolves, and the anthropic provider strips a trailing /v1 from base_url so a pasted OpenAI-shape URL no longer produces /v1/v1/messages.
dorokuma
pushed a commit
to dorokuma/DeepSeek-Reasonix
that referenced
this pull request
Jun 10, 2026
…hat client (esengine#3669) Wizard now probes the same candidate URLs (root + /v1 + compat suffixes) the chat client resolves, and the anthropic provider strips a trailing /v1 from base_url so a pasted OpenAI-shape URL no longer produces /v1/v1/messages.
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.
🤖 Generated by AI (CnsMaple + Reasonix)
Problem
The setup wizard probes custom providers with the user's
base_url, but thechat client later normalises the URL through the OpenAI/Anthropic shape
detection (adds
/v1if missing). The two paths disagreed: a wizard probethat succeeded against
https://api.example.comcould fail at chat time, orvice versa.
Fix
The setup wizard now normalises
base_urlthe same way the chat providers do(
/v1suffix added if missing, trailing slashes stripped) before using itfor the probe and persisting it.
internal/provider/anthropicmirrors thesame normalisation in its
BaseURLgetter so both legs of thewizard-to-chat pipeline agree on the URL shape.
Changes
internal/cli/cli.go(+41/-1): normalise custom-provider base_url in the setup wizard.internal/cli/cli_test.go(+85): table-driven coverage for the normalisation cases.internal/provider/anthropic/anthropic.go(+17/-1): consistent BaseURL normalisation.internal/provider/anthropic/anthropic_test.go(+40): sub-tests for/v1, trailing slash, path prefix, empty fallback.Tests
go test ./internal/cli/ ./internal/provider/anthropic/ -count=1 -run 'SetupBaseURL|CustomProvider|BaseURL'→ all new tests pass.
esengine:main-v2 @ 90c24655.