fix: retry Amazon Bedrock network connection lost errors#5569
fix: retry Amazon Bedrock network connection lost errors#5569kevinvandijk merged 3 commits intoKilo-Org:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 30eb061 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Awesome, thanks for the fix! When can we expect it to be released? |
|
Still encountering the error. It's a real road blocker. Kilo speed, guys! Should a PR review take weeks, really? |
|
A small amount of queries are consistently timing out on both Bedrock and Anthropic. We are investigating, unfortunately retrying is unlikely to help as in our analysis so far it is a consistent error once in this state. |
| const isBedrockNetworkError = | ||
| msg.includes("Amazon Bedrock error") && msg.includes("Network connection lost") | ||
|
|
||
| if (isBedrockNetworkError && attempts < 3) { |
There was a problem hiding this comment.
WARNING: The retry logic is correct but lacks test coverage.
Per the project's code quality rules, all code changes should have test coverage. The existing test file src/api/providers/__tests__/openrouter.spec.ts should be updated with tests for this retry behavior, covering:
- Successful request on first attempt (no retry)
- Bedrock network error followed by successful retry
- Exhausting all 3 attempts and throwing the error
- Non-Bedrock errors being thrown immediately without retry
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
|
kevinvandijk
left a comment
There was a problem hiding this comment.
I don't think this is the right solution but it can't hurt to have a retry option in here I think. Thanks!
| msg.includes("Amazon Bedrock error") && msg.includes("Network connection lost") | ||
|
|
||
| if (isBedrockNetworkError && attempts < 3) { | ||
| console.log(`[OpenRouter] Retrying Bedrock network error (attempt ${attempts}/3): ${msg}`) |
There was a problem hiding this comment.
WARNING: Off-by-one in retry count — the condition attempts < 3 on line 444 allows only 2 retries (3 total attempts), but the changeset says "up till 3 times" and this log message says attempt ${attempts}/3 which will only ever print 1/3 and 2/3, never 3/3.
If the intent is 3 retries (as the changeset states), change the condition to attempts <= 3. If 2 retries is intentional, update the log to attempt ${attempts}/2 and the changeset description.
Context
fixes #5563
Implementation
Implements an automatic retry mechanism (up to 3 attempts with exponential backoff) for "Amazon Bedrock error: Network connection lost" failures in the OpenRouter provider to improve stability with large contexts.
How to Test
Launch the Extension: Run the extension in debug mode (F5).
Select a Model: Choose a model that routes through Amazon Bedrock (e.g., Claude 3.5 Sonnet via OpenRouter or openai/gpt-5.2-codex if applicable).
Simulate High Load:
Verify Retry Logic:
Get in Touch