From 9d783af2f9a1f470c214c1f1f68d81087970771d Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 30 Dec 2025 01:11:00 -0400 Subject: [PATCH] Improve provider error messages with install suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add "smarttools providers install" suggestion when command not found - Add suggestion when provider exits with error containing "not found" - Detect empty output and warn about unavailable model - Show stderr hint when provider returns nothing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/smarttools/providers.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/smarttools/providers.py b/src/smarttools/providers.py index 731932a..5097884 100644 --- a/src/smarttools/providers.py +++ b/src/smarttools/providers.py @@ -174,7 +174,7 @@ def call_provider(provider_name: str, prompt: str, timeout: int = 300) -> Provid return ProviderResult( text="", success=False, - error=f"Command '{base_cmd}' not found. Is it installed and in PATH?" + error=f"Command '{base_cmd}' not found. Is it installed and in PATH?\n\nTo install AI providers, run: smarttools providers install" ) try: @@ -188,10 +188,22 @@ def call_provider(provider_name: str, prompt: str, timeout: int = 300) -> Provid ) if result.returncode != 0: + error_msg = f"Provider exited with code {result.returncode}: {result.stderr}" + if "not found" in result.stderr.lower() or "not installed" in result.stderr.lower(): + error_msg += "\n\nTo install AI providers, run: smarttools providers install" return ProviderResult( text="", success=False, - error=f"Provider exited with code {result.returncode}: {result.stderr}" + error=error_msg + ) + + # Warn if output is empty (provider ran but returned nothing) + if not result.stdout.strip(): + stderr_hint = f" (stderr: {result.stderr.strip()})" if result.stderr.strip() else "" + return ProviderResult( + text="", + success=False, + error=f"Provider returned empty output{stderr_hint}.\n\nThis may mean the model is not available. Try a different provider or run: smarttools providers install" ) return ProviderResult(text=result.stdout, success=True)