Skip to content

fix(bedrock): run async SigV4 auth off the event loop - #1777

Open
Solaris-star wants to merge 1 commit into
anthropics:mainfrom
Solaris-star:fix/1770-async-bedrock-auth-to-thread
Open

fix(bedrock): run async SigV4 auth off the event loop#1777
Solaris-star wants to merge 1 commit into
anthropics:mainfrom
Solaris-star:fix/1770-async-bedrock-auth-to-thread

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

AsyncAnthropicBedrock._prepare_request called get_auth_headers() synchronously, blocking the event loop during AWS credential resolution and SigV4 signing (#1770).

Fix

Wrap the call in to_thread() (from anthropic._utils._sync) so credential work runs in a worker thread. Same fix applied to AsyncAnthropicBedrockMantle.

Test

Added test_bedrock_async_thread.py — asserts concurrent heartbeats keep firing while auth is slow.

Fixes #1770

AsyncAnthropicBedrock._prepare_request called get_auth_headers
synchronously, blocking the event loop during AWS credential
resolution and SigV4 signing. Use to_thread to run it in a worker
thread so concurrent async tasks keep running.

Same fix applied to AsyncAnthropicBedrockMantle.

Fixes anthropics#1770
@Solaris-star
Solaris-star requested a review from a team as a code owner July 24, 2026 03:53
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.

AsyncAnthropicBedrock blocks the event loop during AWS credential resolution or signing

1 participant