Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #2545 by enhancing model configuration error messages to display available models when a provider returns a "model not supported" error. When a user configures an unsupported model, the enhanced error message will now include a list of recommended models for the provider, reducing friction during initial setup.
Changes:
- Added an
enhance_model_errorfunction that detects model-related errors and appends a list of available models to the error message - Modified the error handling in
reply_message_streamto callenhance_model_errorbefore returning error streams
| }; | ||
|
|
||
| let msg_lower = msg.to_lowercase(); | ||
| if !msg_lower.contains("404") || !msg_lower.contains("model") { |
There was a problem hiding this comment.
This checks for "404" but the linked issue #2545 describes "400 error" scenarios when models are not supported. Based on the issue description and the fact that unsupported model errors typically return 400 Bad Request (not 404 Not Found), this should check for "400" instead of "404".
| if !msg_lower.contains("404") || !msg_lower.contains("model") { | |
| if !msg_lower.contains("400") || !msg_lower.contains("model") { |
There was a problem hiding this comment.
to copilot's point, is it always a 404?
There was a problem hiding this comment.
no idea, but it's a good point
| async fn enhance_model_error(error: ProviderError, provider: &Arc<dyn Provider>) -> ProviderError { | ||
| let ProviderError::RequestFailed(ref msg) = error else { | ||
| return error; | ||
| }; | ||
|
|
||
| let msg_lower = msg.to_lowercase(); | ||
| if !msg_lower.contains("404") || !msg_lower.contains("model") { | ||
| return error; | ||
| } | ||
|
|
||
| let Ok(Some(models)) = provider.fetch_recommended_models().await else { | ||
| return error; | ||
| }; | ||
|
|
||
| ProviderError::RequestFailed(format!( | ||
| "{}. Available models for this provider: {}", | ||
| msg, | ||
| models.join(", ") | ||
| )) | ||
| } |
There was a problem hiding this comment.
The new enhance_model_error function lacks test coverage. Given that other functions in this file have tests, consider adding tests to verify this function correctly identifies model errors (with both "400" and "model" in the message), successfully fetches recommended models, and properly formats the enhanced error message.
| }; | ||
|
|
||
| let msg_lower = msg.to_lowercase(); | ||
| if !msg_lower.contains("404") || !msg_lower.contains("model") { |
There was a problem hiding this comment.
Potential future enhancement: if we get good enough at identifying the kinds of errors that mean a model change is needed, should we open the model selection modal for the user in addition to showing a message?
There was a problem hiding this comment.
yeah, maybe at some point. we can't really here and as a desktop user you shouldn't get into this - this is mostly for the CLI where specify a model that doesn't exist.
| }; | ||
|
|
||
| let msg_lower = msg.to_lowercase(); | ||
| if !msg_lower.contains("404") || !msg_lower.contains("model") { |
There was a problem hiding this comment.
to copilot's point, is it always a 404?
|
LGTM for a merge |
* 'main' of github.com:block/goose: refactor: move disable_session_naming into AgentConfig (#7062) Add global config switch to disable automatic session naming (#7052) docs: add blog post - 8 Things You Didn't Know About Code Mode (#7059) fix: ensure animated elements are visible when prefers-reduced-motion is enabled (#7047) Show recommended model on failture (#7040) feat(ui): add session content search via API (#7050) docs: fix img url (#7053) Desktop UI for deleting custom providers (#7042) Add blog post: How I Used RPI to Build an OpenClaw Alternative (#7051)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
* origin/main: (55 commits) test(mcp): add image tool test and consolidate MCP test fixtures (#7019) fix: remove Option from model listing return types, propagate errors (#7074) fix: lazy provider creation for goose acp (#7026) (#7066) Smoke tests: split compaction test and use debug build (#6984) fix(deps): trim bat to resolve RUSTSEC-2024-0320 (#7061) feat: expose AGENT_SESSION_ID env var to extension child processes (#7072) fix: add XML tool call parsing fallback for Qwen3-coder via Ollama (#6882) Remove clippy too_many_lines lint and decompose long functions (#7064) refactor: move disable_session_naming into AgentConfig (#7062) Add global config switch to disable automatic session naming (#7052) docs: add blog post - 8 Things You Didn't Know About Code Mode (#7059) fix: ensure animated elements are visible when prefers-reduced-motion is enabled (#7047) Show recommended model on failture (#7040) feat(ui): add session content search via API (#7050) docs: fix img url (#7053) Desktop UI for deleting custom providers (#7042) Add blog post: How I Used RPI to Build an OpenClaw Alternative (#7051) Remove build-dependencies section from Cargo.toml (#6946) add /rp-why skill blog post (#6997) fix: fix snake_case function names in code_execution instructions (#7035) ... # Conflicts: # scripts/test_subrecipes.sh
* main: (101 commits) fix: lazy provider creation for goose acp (#7026) (#7066) Smoke tests: split compaction test and use debug build (#6984) fix(deps): trim bat to resolve RUSTSEC-2024-0320 (#7061) feat: expose AGENT_SESSION_ID env var to extension child processes (#7072) fix: add XML tool call parsing fallback for Qwen3-coder via Ollama (#6882) Remove clippy too_many_lines lint and decompose long functions (#7064) refactor: move disable_session_naming into AgentConfig (#7062) Add global config switch to disable automatic session naming (#7052) docs: add blog post - 8 Things You Didn't Know About Code Mode (#7059) fix: ensure animated elements are visible when prefers-reduced-motion is enabled (#7047) Show recommended model on failture (#7040) feat(ui): add session content search via API (#7050) docs: fix img url (#7053) Desktop UI for deleting custom providers (#7042) Add blog post: How I Used RPI to Build an OpenClaw Alternative (#7051) Remove build-dependencies section from Cargo.toml (#6946) add /rp-why skill blog post (#6997) fix: fix snake_case function names in code_execution instructions (#7035) Document max_turns settings for recipes and subagents (#7044) feat: update Groq declarative data with Preview Models (#7023) ...
* origin/main: (54 commits) chore: strip posthog for sessions/models/daily only (#7079) tidy: clean up old benchmark and add gym (#7081) fix: use command.process_group(0) for CLI providers, not just MCP (#7083) added build notify (#6891) test(mcp): add image tool test and consolidate MCP test fixtures (#7019) fix: remove Option from model listing return types, propagate errors (#7074) fix: lazy provider creation for goose acp (#7026) (#7066) Smoke tests: split compaction test and use debug build (#6984) fix(deps): trim bat to resolve RUSTSEC-2024-0320 (#7061) feat: expose AGENT_SESSION_ID env var to extension child processes (#7072) fix: add XML tool call parsing fallback for Qwen3-coder via Ollama (#6882) Remove clippy too_many_lines lint and decompose long functions (#7064) refactor: move disable_session_naming into AgentConfig (#7062) Add global config switch to disable automatic session naming (#7052) docs: add blog post - 8 Things You Didn't Know About Code Mode (#7059) fix: ensure animated elements are visible when prefers-reduced-motion is enabled (#7047) Show recommended model on failture (#7040) feat(ui): add session content search via API (#7050) docs: fix img url (#7053) Desktop UI for deleting custom providers (#7042) ...
* origin/main: (141 commits) Add global config switch to disable automatic session naming (#7052) docs: add blog post - 8 Things You Didn't Know About Code Mode (#7059) fix: ensure animated elements are visible when prefers-reduced-motion is enabled (#7047) Show recommended model on failture (#7040) feat(ui): add session content search via API (#7050) docs: fix img url (#7053) Desktop UI for deleting custom providers (#7042) Add blog post: How I Used RPI to Build an OpenClaw Alternative (#7051) Remove build-dependencies section from Cargo.toml (#6946) add /rp-why skill blog post (#6997) fix: fix snake_case function names in code_execution instructions (#7035) Document max_turns settings for recipes and subagents (#7044) feat: update Groq declarative data with Preview Models (#7023) fix(codex): propagate extended PATH to codex subprocess (#6874) Switch tetrate tool filtering back to supports_computer_use (#7024) feat(ui): add inline rename for chat sessions in sidebar (#6995) fix: handle toolnames without underscores (#7015) feat(claude-code): use stream-json protocol for persistent sessions (#7029) test(providers): add model listing to live provider suite (#7038) Agent added too much (#7036) ...
Co-authored-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
Summary
Fixes: #2545