Skip to content

fix(aws): let AnthropicAWS.copy() accept credentials=None so environment helpers work on Claude Platform on AWS#1737

Open
csantanapr wants to merge 1 commit into
anthropics:mainfrom
csantanapr:fix/aws-client-copy-credentials
Open

fix(aws): let AnthropicAWS.copy() accept credentials=None so environment helpers work on Claude Platform on AWS#1737
csantanapr wants to merge 1 commit into
anthropics:mainfrom
csantanapr:fix/aws-client-copy-credentials

Conversation

@csantanapr

Copy link
Copy Markdown

Fixes #1736.

Problem

The self-hosted environment work helpers — client.beta.environments.work.poller(), EnvironmentWorker, and SessionToolRunner — build a scoped sub-client via _copy_client_with_bearer_auth, which calls client.copy(credentials=None, ...). AnthropicAWS.copy() / AsyncAnthropicAWS.copy() intentionally omit credentials, so on the AWS platform these helpers raise before making any request:

TypeError: AsyncAnthropicAWS.copy() got an unexpected keyword argument 'credentials'

This makes the self-hosted environment poller and worker unusable on Claude Platform on AWS. Reproduced on anthropic==0.116.0 (latest release). Full repro in #1736.

Fix

Accept credentials on the AWS copy() overrides:

  • None (the value the internal helper passes) → no-op. The AWS client authenticates with SigV4 (or an API key) and has no token-provider credential to clear, so the scoped sub-client is returned unchanged auth-wise and keeps signing with SigV4.
  • A real provider → TypeError with a clear message, rather than silently ignoring it.

The change is confined to src/anthropic/lib/aws/_client.py (which the code generator never touches) and fixes all four call sites at once.

Tests

Added to tests/lib/test_aws.py:

  • test_copy_accepts_credentials_none_noopcopy(credentials=None) stays SigV4, preserves workspace/region.
  • test_copy_rejects_real_credentials_provider — a real provider raises TypeError.
  • test_scoped_bearer_client_helper_on_aws / _async — the exact _copy_client_with_bearer_auth path the poller/worker use now works on both sync and async AWS clients.

tests/lib/test_aws.py passes (39 passed); full tests/lib/ suite passes (752 passed, 1 skipped, 1 xfailed); ruff check and ruff format clean.

…ent helpers work

The environment work helpers — `client.beta.environments.work.poller()`,
`EnvironmentWorker`, and `SessionToolRunner` — build a scoped sub-client via
`_copy_client_with_bearer_auth`, which calls `client.copy(credentials=None, ...)`.
`AnthropicAWS.copy()` / `AsyncAnthropicAWS.copy()` intentionally omit the
`credentials` parameter, so these helpers raise `TypeError: copy() got an
unexpected keyword argument 'credentials'` on the AWS client — making the
self-hosted environment poller/worker unusable on Claude Platform on AWS.

Accept `credentials` on the AWS `copy()` overrides as a no-op when None (the AWS
client authenticates with SigV4 / an API key and has no token-provider
credentials), and raise a clear error if a real provider is passed. The scoped
sub-client is returned unchanged auth-wise, so it keeps signing with SigV4.

Add regression tests covering copy(credentials=None), rejection of a real
provider, and `_copy_client_with_bearer_auth` on both sync and async AWS clients.
@csantanapr

Copy link
Copy Markdown
Author

Real-world validation

I've validated this fix end-to-end using Amazon EKS as the self-hosted environment, with the in-cluster poller/worker authenticating to Claude Platform on AWS via EKS Pod Identity (SigV4, cross-account role chaining — the EKS Pod Identity role in the cluster account assuming a target role in the Claude Platform account). With the fix applied, client.beta.environments.work.poller() polls the work queue successfully over SigV4 (GET https://aws-external-anthropic.<region>.api.aws/v1/environments/.../work/poll → 200), the worker services sessions, and end-to-end runs complete with no errors — no environment key or API key anywhere in the cluster, IAM/SigV4 only.

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.

AnthropicAWS.copy() rejects credentials=None, breaking the self-hosted environment poller/worker on Claude Platform on AWS

1 participant