continuedev/continue · error · Error

AWS Bedrock stream error (${(error as any).code}): ${error.m

Error message

AWS Bedrock stream error (${(error as any).code}): ${error.message}

What it means

Thrown when the AWS Bedrock converse/invoke streaming call fails with an error that carries a `code` property (typical of AWS SDK v3 service exceptions like ThrottlingException, ModelStreamErrorException, or AccessDeniedException). The adapter wraps the raw AWS error and prefixes it with 'AWS Bedrock stream error' plus the AWS error code so the underlying cause is visible. It originates from the catch block of chatCompletionStream, which is also reused by chatCompletionNonStream.

Source

Thrown at packages/openai-adapters/src/apis/Bedrock.ts:562

                  {
                    index: 0,
                    id: start.toolUse.toolUseId,
                    type: "function",
                    function: {
                      name: start.toolUse.name,
                      arguments: undefined,
                    },
                  },
                ],
              },
            });
          }
        }
      }
    } catch (error) {
      if (error instanceof Error) {
        if ("code" in error) {
          throw new Error(
            `AWS Bedrock stream error (${(error as any).code}): ${error.message}`,
          );
        }
        throw new Error(`Error processing Bedrock stream: ${error.message}`);
      }
      throw new Error(
        "Error processing Bedrock stream: Unknown error occurred",
      );
    }
  }

  completionNonStream(
    body: CompletionCreateParamsNonStreaming,
  ): Promise<Completion> {
    throw new Error("Bedrock does not support completions API");
  }

  completionStream(

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Read the parenthesized AWS code in the message (e.g. ThrottlingException) and fix the corresponding cause: enable the model in the Bedrock console, verify credentials/region, or request a quota increase.
  2. Add exponential-backoff retry around the call for ThrottlingException / ServiceUnavailable codes.
  3. Verify the modelId string exactly matches a Bedrock-supported identifier (e.g. anthropic.claude-3-5-sonnet-...) and that it supports streaming.
  4. If behind a proxy or cross-region setup, confirm network egress to bedrock-runtime.<region>.amazonaws.com is allowed.

Example fix

// before
const stream = await api.chatCompletionStream(body);

// after
try {
  const stream = await api.chatCompletionStream(body);
} catch (e) {
  if (e instanceof Error && e.message.startsWith('AWS Bedrock stream error')) {
    const code = e.message.match(/\((.*?)\)/)?.[1];
    if (code === 'ThrottlingException') await backoffAndRetry();
  }
  throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check model availability & config before streaming
import { BedrockRuntimeClient, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime';
const probe = await client.send(new InvokeModelCommand({ modelId, body: JSON.stringify({ inputText: 'ping' }) }));

Type guard

function isBedrockServiceError(e: unknown): e is Error & { code: string } {
  return e instanceof Error && 'code' in e;
}

Try / catch

try {
  await api.chatCompletionStream(body);
} catch (e) {
  const m = e instanceof Error ? e.message : String(e);
  if (m.startsWith('AWS Bedrock stream error')) {
    const code = m.match(/\((.*?)\)/)?.[1] ?? '';
    if (['ThrottlingException', 'ServiceUnavailableException'].includes(code)) return retryWithBackoff();
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling chatCompletionStream (or chatCompletionNonStream) and the underlying Bedrock InvokeModelWithResponseStreamCommand fails mid-stream: throttling (code: ThrottlingException), model not entitled (AccessDeniedException), invalid modelId (ValidationException), or network/credential errors surfaced by the AWS SDK with a `code` field.

Common situations: Missing or wrong AWS credentials/region in config; using a model ID not enabled for the account; hitting Bedrock rate limits or account quotas; streaming a non-streaming-capable model; AWS SDK v3 middleware errors that annotate `code`.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/7bc3466a1b4ee745. Report an issue: GitHub.