Summary
On Claude Platform on AWS, the self-hosted environment work helpers crash with a TypeError before making any request, because they build a Bearer-scoped sub-client that the AWS client's copy() cannot produce. This makes the self-hosted environment poller and worker unusable with AnthropicAWS / AsyncAnthropicAWS.
Affected version
Reproduced on the latest release, anthropic==0.116.0 (anthropic[aws]).
Root cause
anthropic/lib/_scoped_client.py::_copy_client_with_bearer_auth scopes a sub-client with:
scoped = client.copy(
auth_token=auth_token,
credentials=None,
default_headers={STAINLESS_HELPER_HEADER: helper},
)
But AnthropicAWS.copy() / AsyncAnthropicAWS.copy() (in anthropic/lib/aws/_client.py) intentionally omit the credentials parameter, so the call raises:
TypeError: AsyncAnthropicAWS.copy() got an unexpected keyword argument 'credentials'
This helper is called by every self-hosted environment helper:
resources/beta/environments/work.py::poller() (line ~1176)
lib/environments/_worker.py::EnvironmentWorker (lines ~311, ~393)
lib/tools/_beta_session_runner.py (line ~221)
so none of them work on the AWS platform.
Reproduction
import asyncio
from anthropic import AsyncAnthropicAWS
async def main():
client = AsyncAnthropicAWS(
aws_access_key="AKIAFAKE", aws_secret_key="fake",
aws_region="us-west-2", workspace_id="wrkspc_example",
)
it = client.beta.environments.work.poller(
environment_id="env_example",
environment_key="unused-on-aws", # required kwarg
auto_stop=False,
)
async for _ in it: # raises before the first poll
break
asyncio.run(main())
Result:
File ".../anthropic/resources/beta/environments/work.py", line 1176, in poller
scoped = _copy_client_with_bearer_auth(...)
File ".../anthropic/lib/_scoped_client.py", line 57, in _copy_client_with_bearer_auth
scoped = client.copy(...)
TypeError: AsyncAnthropicAWS.copy() got an unexpected keyword argument 'credentials'
The same TypeError occurs via EnvironmentWorker(...).handle_item() on the AWS client.
Expected behavior
The environment poller/worker should work on Claude Platform on AWS. The AWS client authenticates with SigV4 (or an API key), so there is no token-provider credential to swap — copy(credentials=None) should be a no-op that returns a sub-client still signing with SigV4.
Proposed fix
Let the AWS copy() overrides accept credentials (no-op when None, error on a real provider). This fixes all four call sites at once and lives entirely in src/anthropic/lib/ (never regenerated). PR: I'll link it below.
Environment
anthropic 0.116.0 with the aws extra (botocore 1.43.x)
- Python 3.12
Summary
On Claude Platform on AWS, the self-hosted environment work helpers crash with a
TypeErrorbefore making any request, because they build a Bearer-scoped sub-client that the AWS client'scopy()cannot produce. This makes the self-hosted environment poller and worker unusable withAnthropicAWS/AsyncAnthropicAWS.Affected version
Reproduced on the latest release,
anthropic==0.116.0(anthropic[aws]).Root cause
anthropic/lib/_scoped_client.py::_copy_client_with_bearer_authscopes a sub-client with:But
AnthropicAWS.copy()/AsyncAnthropicAWS.copy()(inanthropic/lib/aws/_client.py) intentionally omit thecredentialsparameter, so the call raises:This helper is called by every self-hosted environment helper:
resources/beta/environments/work.py::poller()(line ~1176)lib/environments/_worker.py::EnvironmentWorker(lines ~311, ~393)lib/tools/_beta_session_runner.py(line ~221)so none of them work on the AWS platform.
Reproduction
Result:
The same
TypeErroroccurs viaEnvironmentWorker(...).handle_item()on the AWS client.Expected behavior
The environment poller/worker should work on Claude Platform on AWS. The AWS client authenticates with SigV4 (or an API key), so there is no token-provider credential to swap —
copy(credentials=None)should be a no-op that returns a sub-client still signing with SigV4.Proposed fix
Let the AWS
copy()overrides acceptcredentials(no-op whenNone, error on a real provider). This fixes all four call sites at once and lives entirely insrc/anthropic/lib/(never regenerated). PR: I'll link it below.Environment
anthropic0.116.0 with theawsextra (botocore1.43.x)