Skip to content

fix: surface provider API errors instead of showing empty response#5176

Open
superShen0916 wants to merge 1 commit into
Aider-AI:mainfrom
superShen0916:fix/surface-provider-errors
Open

fix: surface provider API errors instead of showing empty response#5176
superShen0916 wants to merge 1 commit into
Aider-AI:mainfrom
superShen0916:fix/surface-provider-errors

Conversation

@superShen0916
Copy link
Copy Markdown

Summary

Fixes #3264 — When OpenRouter or other providers return rate-limit (429) or insufficient-credits (402) errors, LiteLLM may wrap the error in a response object rather than raising an exception. Previously, aider showed "0 received" with no explanation, leaving users confused about why no response was generated.

Changes

  1. Detect API errors in completion responses (send() in base_coder.py): After send_completion returns, check if the response has an error field (populated by LiteLLM for API-level errors). If present, display the error message via tool_error and return early — avoiding the misleading token report.

  2. Improve empty-response warning (show_send_output_stream): Replace the generic "Empty response received from LLM. Check your provider account?" with a more actionable message that mentions rate limits, insufficient credits, and provider availability as likely causes, and suggests --verbose for debugging.

Test plan

  • The error path only activates when completion.error is populated (currently for provider errors that LiteLLM wraps in a response)
  • Successful responses are unaffected — the error check returns None/falsy for normal completions
  • The improved warning message is a string change only

Risk

Low. The error check is defensive and only fires when the provider returns an explicit error object. All existing success paths are unchanged.

🤖 Generated with Claude Code

When OpenRouter or other providers return rate-limit (429) or
insufficient-credits (402) errors, LiteLLM may wrap the error in a
response object rather than raising an exception. Previously, aider
showed "0 received" with no explanation, leaving users confused.

This change:
- Checks the completion response for an error field before processing
- Displays the provider error message to the user when found
- Improves the empty-response warning to mention rate limits and
  credits as likely causes

Fixes Aider-AI#3264

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aider shows no response when OpenRouter free models run out of rate limit

1 participant