fix(providers): fall back to configured models when models endpoint fetch fails#7530
fix(providers): fall back to configured models when models endpoint fetch fails#7530DOsinga merged 13 commits intoblock:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d23ffce1f4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…mented errors Auth failures (401/403), rate limits (429), and server errors (5xx) now propagate correctly instead of being hidden by fallback. Only 404 and connection failures trigger fallback to preserve diagnostics. Fixes P1 feedback from PR block#7530
Custom providers with models defined in JSON config would fail when switching models in the Desktop UI because the code always tried to fetch from the /v1/models API endpoint, which many proxies don't implement. Now, for custom providers that define a models list: - Try to fetch models from /v1/models API first - On any error, gracefully fallback to predefined models from config - Log a debug message when falling back Backwards compatible: providers without custom models must still succeed with the API call (unchanged behavior). Fixes GitHub issue block#7427. Signed-off-by: Pete Gonzalez <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 664cc3f2cc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…mented errors Auth failures (401/403), rate limits (429), and server errors (5xx) now propagate correctly instead of being hidden by fallback. Only 404 and connection failures trigger fallback to preserve diagnostics. Fixes P1 feedback from PR block#7530 Signed-off-by: Pete Gonzalez <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e38b52c7f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Connection failures should not trigger fallback to custom models - they indicate the provider host is down, not that the models endpoint is missing. This preserves diagnostics for outages. Addresses second P1 feedback from PR block#7530. Signed-off-by: Pete Gonzalez <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3e88965ec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Using contains("404") could incorrectly match port numbers like localhost:4040
in connection error messages. The 404 status code is always formatted as "(404)"
in error messages from map_http_error_to_provider_error.
Addresses third P1 feedback from PR block#7530.
Signed-off-by: Pete Gonzalez <[email protected]>
|
thanks for diving onto this and sorry for the late reply two things:
|
DOsinga
left a comment
There was a problem hiding this comment.
The fix is correct and tightly scoped — the fallback only activates when custom_models is explicitly configured, so normal OpenAI/Anthropic flows are completely unaffected. Codex comments were all addressed well. I cleaned up a few inline comments that restated what the code already said clearly, and rebased onto main.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 073cc65212
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
crates/goose/src/providers/errors.rs
Outdated
|
|
||
| pub fn is_endpoint_not_implemented(&self) -> bool { | ||
| match self { | ||
| ProviderError::RequestFailed(msg) => msg.contains("(404)"), |
There was a problem hiding this comment.
Match endpoint-not-implemented on status, not message text
ProviderError::is_endpoint_not_implemented() currently checks RequestFailed text with msg.contains("(404)"), which can misclassify non-404 failures whenever the upstream error payload happens to include that substring (for example, a 400/405 response message mentioning 404). In that case fetch_supported_models() in the OpenAI/Anthropic providers will incorrectly return custom_models and hide the real API error. Because RequestFailed embeds arbitrary server text, this detection should use structured status information instead of substring matching.
Useful? React with 👍 / 👎.
…ring matching Signed-off-by: Douwe Osinga <[email protected]>
DOsinga
left a comment
There was a problem hiding this comment.
Thanks for the fix and for addressing all the codex comments thoroughly — the fallback logic is tightly scoped and correct.
I've pushed two small follow-up commits to your branch:
- Removed inline comments that restated what the code already said clearly, and collapsed the nested
match/ifinto a cleaner guard pattern. - Addressed the copilot P2: replaced the
msg.contains("(404)")substring check with a dedicatedProviderError::EndpointNotFoundvariant, emitted structurally frommap_http_error_to_provider_errorwhen the HTTP status is exactly 404. This means a 400/405 response whose body happens to contain(404)will no longer be mistaken for a missing endpoint. Added two test cases covering 404 with and without a payload that itself contains a404substring.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39181a57b0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| StatusCode::NOT_FOUND => { | ||
| ProviderError::RequestFailed(format!("Resource not found (404): {}", extract_message())) | ||
| } | ||
| StatusCode::NOT_FOUND => ProviderError::EndpointNotFound(extract_message()), |
There was a problem hiding this comment.
Keep inference 404s as RequestFailed for model hints
Mapping every 404 to EndpointNotFound here regresses the model-recommendation flow for failed inference calls. Agent::enhance_model_error in agents/reply_parts.rs only augments ProviderError::RequestFailed with “available models” suggestions, so a /chat/completions response like “model ... not found” now skips that path and surfaces a less actionable generic error. This is a user-visible regression from the previous RequestFailed mapping for 404 responses.
Useful? React with 👍 / 👎.
…stFailed for inference 404s The shared map_http_error_to_provider_error was changed to emit EndpointNotFound for all 404 responses, but enhance_model_error in reply_parts.rs only augments RequestFailed errors with available-model suggestions. A /chat/completions 404 (e.g. 'model X not found') would skip that path and surface a less actionable error. Fix: emit EndpointNotFound only from fetch_models_from_api (where we actually want the custom-models fallback), and keep the shared 404 mapper returning RequestFailed so inference errors still get the model-recommendation enhancement. Signed-off-by: Douwe Osinga <[email protected]>
DOsinga
left a comment
There was a problem hiding this comment.
Addressed the remaining Codex P2 about EndpointNotFound regressing the model-recommendation flow.
The fix in 6c756b50: instead of emitting EndpointNotFound from the shared map_http_error_to_provider_error (which is used for all HTTP calls including inference), the 404→EndpointNotFound conversion now only happens inside fetch_models_from_api on both OpenAI and Anthropic providers. The shared mapper keeps returning RequestFailed for 404s, so enhance_model_error in reply_parts.rs continues to match inference 404s and append the helpful "Available models" suggestion.
# Conflicts: # crates/goose/src/providers/openai.rs
Signed-off-by: Douwe Osinga <[email protected]>
* main: (337 commits) fix: replace panics with user-friendly errors in CLI session builder (#7901) fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900) fix: deliver truncation notice as separate content block (#7899) fix: use platform-appropriate commands in developer extension instructions (#7898) fix: replace any with proper SVG types in icon components (#7873) chore: remove debug console.log statements, stale comments, and dead code (#8142) feat: Gemini OAuth provider (#8129) chore(deps): bump picomatch from 2.3.1 to 2.3.2 in /documentation (#8123) feat: show installed skills in UI (#7910) fix(deps): gate keyring platform features behind target-specific deps (#8039) chore(deps): bump yaml from 2.8.2 to 2.8.3 in /evals/open-model-gym/suite (#8124) fix: strip message wrapper in CLI session title generation (#7996) fix(providers): fall back to configured models when models endpoint fetch fails (#7530) chore(deps): bump brace-expansion from 5.0.3 to 5.0.5 in /evals/open-model-gym/suite (#8139) fix: prevent Ollama provider from hanging on tool-calling requests (#7723) fix: VMware Tanzu Platform provider - bug fixes, streaming, UI improvements (#8126) feat: allow GOOSE_CLI_SHOW_THINKING to be set in config.yaml (#8097) fix: GitHub Copilot auth fails to open browser in Desktop app (#6957) (#8019) fix(ci): produce .tar.gz archives for Zed ACP registry compatibility (#8054) feat: add GOOSE_SHOW_FULL_OUTPUT config to disable tool output truncation (#7919) ... # Conflicts: # crates/goose/src/providers/formats/openai.rs
…etch fails (block#7530) Signed-off-by: Pete Gonzalez <[email protected]> Signed-off-by: Douwe Osinga <[email protected]> Co-authored-by: Pete Gonzalez <[email protected]> Co-authored-by: Douwe Osinga <[email protected]> Signed-off-by: Cameron Yick <[email protected]>
|
Thanks very much! 🚀 |
* main: (337 commits) fix: replace panics with user-friendly errors in CLI session builder (#7901) fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900) fix: deliver truncation notice as separate content block (#7899) fix: use platform-appropriate commands in developer extension instructions (#7898) fix: replace any with proper SVG types in icon components (#7873) chore: remove debug console.log statements, stale comments, and dead code (#8142) feat: Gemini OAuth provider (#8129) chore(deps): bump picomatch from 2.3.1 to 2.3.2 in /documentation (#8123) feat: show installed skills in UI (#7910) fix(deps): gate keyring platform features behind target-specific deps (#8039) chore(deps): bump yaml from 2.8.2 to 2.8.3 in /evals/open-model-gym/suite (#8124) fix: strip message wrapper in CLI session title generation (#7996) fix(providers): fall back to configured models when models endpoint fetch fails (#7530) chore(deps): bump brace-expansion from 5.0.3 to 5.0.5 in /evals/open-model-gym/suite (#8139) fix: prevent Ollama provider from hanging on tool-calling requests (#7723) fix: VMware Tanzu Platform provider - bug fixes, streaming, UI improvements (#8126) feat: allow GOOSE_CLI_SHOW_THINKING to be set in config.yaml (#8097) fix: GitHub Copilot auth fails to open browser in Desktop app (#6957) (#8019) fix(ci): produce .tar.gz archives for Zed ACP registry compatibility (#8054) feat: add GOOSE_SHOW_FULL_OUTPUT config to disable tool output truncation (#7919) ... # Conflicts: # crates/goose/src/providers/formats/openai.rs
Summary
Custom providers with a predefined
modelslist could fail in Desktop when Goose attempted to fetch models from the provider API and the endpoint was not implemented. This change falls back to the configuredmodelslist if the API request fails.Changes
custom_modelsfrom custom provider config.Why
Supports OpenAI-/Anthropic-compatible proxies and gateways that do not expose a models endpoint.
Fixes #7427
CC @tltsaia