[BUG] Bedrock "Session token not found or invalid" on interactive requests despite valid, confirmed-working credentials
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Bug Report: Bedrock "Session token not found or invalid" on interactive requests despite valid, confirmed-working credentials
Environment
- Claude Code version: 2.1.207
- OS: Ubuntu 26.04 on WSL2 (Windows)
- AWS CLI version: 2.35.1
- Installed via:
curl -fsSL https://claude.ai/install.sh | bash - Auth method: AWS SSO (also reproduced with static IAM credentials — see below)
- Region: eu-central-1
- Model: eu.anthropic.claude-sonnet-4-6
What's Wrong
Every interactive request in Claude Code fails immediately with:
"API Error: UnauthorizedException: Session token not found or invalid"
This happens on every prompt, every session, regardless of restart, model pinning, or reinstall — despite credentials being fully valid and independently confirmed to work for the same model, region, and account.
What I've Ruled Out
- No conflicting
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKENenv vars (env | grep -i AWS_clean, onlyAWS_PROFILEset) ~/.aws/configSSO profile correctly configured,aws sso loginsucceedsaws sts get-caller-identitysucceeds and returns the expected role/user- Claude Code's own setup wizard ("choose different models") successfully test-invokes the same model (
eu.anthropic.claude-sonnet-4-6) with a one-token request - Raw
aws bedrock-runtime invoke-modelsucceeds with the same SSO credentials, same model, same region — full response returned - Raw
aws bedrock-runtime invoke-modelalso succeeds with static IAM credentials (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, no session token) — ruling out session-token-specific handling as the cause - Claude Code fails identically with static IAM credentials as with SSO — same error, same behavior
- Fresh reinstall via the official installer (
curl -fsSL https://claude.ai/install.sh | bash -s -- --force) — same failure persists - System clock synchronized, NTP active (
timedatectl statusconfirms) - Claude Code auto-update: confirmed same version installed as a coworker who does not reproduce this bug
- Confirmed AWS_REGION was explicitly exported before testing (per a comment on #54083 suggesting this as a fix for a similar issue) — did not resolve the problem in this case.
Comparison with a non-repro coworker (same team, same AWS account/org)
| | Me (repro) | Coworker (no repro) |
|---|---|---|
| Claude Code version | 2.1.207 | 2.1.207 |
| AWS CLI version | 2.35.1 | 2.34.46 |
| Ubuntu version (WSL2) | 26.04 | 24.04 |
| Region | eu-central-1 | eu-central-1 |
| Auth method | SSO | SSO |
The Ubuntu version difference (26.04 vs 24.04 LTS) is the most notable remaining variable — 26.04 ships newer OpenSSL/glibc that Claude Code's bundled Node.js binary links against at runtime, which could plausibly affect low-level request signing behavior in a way that wouldn't show up in the separately-bundled system AWS CLI.
Timeline
- Was working normally as of ~3 hours before the first occurrence
- WSL2 crashed once before the error first appeared (noting this as context only — clock was confirmed synced afterward, so this may be coincidental rather than causative)
What Should Happen?
Claude Code should successfully authenticate and dispatch requests to Bedrock using the same credentials that are independently confirmed to work via the AWS CLI and Claude Code's own setup wizard.
Error Messages/Logs
2026-07-11T15:07:48.034Z [DEBUG] attribution header x-anthropic-billing-header: cc_version=2.1.207.19f; cc_entrypoint=cli;
2026-07-11T15:07:48.063Z [DEBUG] [API:timing] dispatching to bedrock model=eu.anthropic.claude-haiku-4-5-20251001-v1:0
2026-07-11T15:07:48.068Z [DEBUG] [API:auth] resolving default AWS provider chain (region: eu-central-1)
2026-07-11T15:07:48.270Z [ERROR] API error (attempt 1/11): UnauthorizedException: Session token not found or invalid
2026-07-11T15:07:48.807Z [DEBUG] [API:auth] AWS credential resolve start
2026-07-11T15:07:48.807Z [DEBUG] Fetching AWS caller identity for AWS auth refresh command
2026-07-11T15:07:49.859Z [DEBUG] Fetched AWS caller identity, skipping AWS auth refresh command
2026-07-11T15:07:49.860Z [DEBUG] [API:auth] AWS credential resolve done in 1052ms
2026-07-11T15:07:49.861Z [DEBUG] [API:timing] dispatching to bedrock model=eu.anthropic.claude-haiku-4-5-20251001-v1:0
2026-07-11T15:07:49.864Z [DEBUG] [API:auth] resolving default AWS provider chain (region: eu-central-1)
2026-07-11T15:07:49.916Z [ERROR] API error (attempt 2/11): UnauthorizedException: Session token not found or invalid
2026-07-11T15:07:51.022Z [DEBUG] [API:auth] AWS credential resolve start
2026-07-11T15:07:51.022Z [DEBUG] Fetching AWS caller identity for AWS auth refresh command
2026-07-11T15:07:52.042Z [DEBUG] Fetched AWS caller identity, skipping AWS auth refresh command
2026-07-11T15:07:52.042Z [DEBUG] [API:auth] AWS credential resolve done in 1019ms
2026-07-11T15:07:52.042Z [DEBUG] [API:timing] dispatching to bedrock model=eu.anthropic.claude-haiku-4-5-20251001-v1:0
2026-07-11T15:07:52.044Z [DEBUG] [API:auth] resolving default AWS provider chain (region: eu-central-1)
2026-07-11T15:07:52.217Z [ERROR] API error (attempt 3/11): UnauthorizedException: Session token not found or invalid
2026-07-11T15:07:52.227Z [ERROR] Error in API request: UnauthorizedException: Session token not found or invalid
2026-07-11T15:07:52.236Z [DEBUG] [shoji-engine] turn 1 end (turns=1 usage in=0 out=0 cost=$0.0000 api=0ms stop=stop_sequence resultLen=0)
2026-07-11T15:07:52.237Z [ERROR] [shoji] turn ended in error: API Error: UnauthorizedException: Session token not found or invalid
Steps to Reproduce
Steps to Reproduce
- Set up AWS SSO authentication for Amazon Bedrock in
~/.aws/config:
[sso-session my-sso]
sso_start_url = https://******.awsapps.com/start
sso_region = eu-north-1
sso_registration_scopes = scope
[profile my-profile]
sso_session = session
sso_account_id = my-id
sso_role_name = my-role
region = eu-central-1
output = json
- Authenticate:
export AWS_PROFILE=my-profile
aws sso login --profile my-profile
- Confirm credentials resolve correctly outside Claude Code:
aws sts get-caller-identity --profile my-profile
→ Returns valid identity.
- Confirm the same credentials work directly against Bedrock:
aws bedrock-runtime invoke-model
--model-id eu.anthropic.claude-sonnet-4-6
--body '{"anthropic_version":"bedrock-2023-05-31","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
--region eu-central-1
--profile my-profile
--cli-binary-format raw-in-base64-out
output.txt
→ Returns a valid model response.
- Launch Claude Code with Bedrock enabled:
export CLAUDE_CODE_USE_BEDROCK=1
claude
- Use the setup wizard to select/pin the model (
eu.anthropic.claude-sonnet-4-6) — the wizard's own one-token test call succeeds. - Send any prompt in the resulting interactive session.
Actual Behavior
Step 7 fails immediately with:
API Error: UnauthorizedException: Session token not found or invalid
This happens on every prompt, every session — even immediately after the successful wizard test in step 6, with no configuration changes in between.
Expected Behavior
The interactive session should authenticate successfully, using the same credentials that steps 3, 4, and 6 already confirm are valid.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.207 (Claude Code)
Platform
AWS Bedrock
Operating System
Windows
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
- This may not be a true regression: Claude Code version is identical between my machine (repro) and a coworker's (no repro), suggesting the trigger is environment-specific (see Ubuntu version comparison above) rather than a code change affecting all users on this version.
- I cannot confirm what Claude Code version was running 3 hours prior when the setup was last working, since Claude Code auto-updates in the background and no local update history was available to check retroactively. It's possible an auto-update occurred around the time of the first failure, though this is unconfirmed.
- Willing to test further if maintainers have specific diagnostics they'd like run (e.g. testing on Ubuntu 24.04 in a fresh WSL distro to directly confirm the OS-version hypothesis, testing with an older/pinned AWS SDK if that's configurable, etc.)
9 Comments
Confirming this also reproduces on macOS (not just WSL2/Windows), so it's not platform-specific.
Environment:
Same "auth succeeds, dispatch fails" pattern, captured via claude --debug api --debug-file ...:
2026-07-11T17:40:33.881Z [DEBUG] [API:auth] AWS credential resolve start
2026-07-11T17:40:33.881Z [DEBUG] Fetching AWS caller identity for AWS auth refresh command
2026-07-11T17:40:36.185Z [DEBUG] Fetched AWS caller identity, skipping AWS auth refresh command
2026-07-11T17:40:36.185Z [DEBUG] [API:auth] AWS credential resolve done in 2304ms
2026-07-11T17:40:36.186Z [DEBUG] [API:auth] resolving default AWS provider chain (region: us-east-1)
2026-07-11T17:40:37.137Z [ERROR] Bedrock ListInferenceProfiles failed: UnauthorizedException: Session token not found or invalid
2026-07-11T17:40:37.138Z [ERROR] Failed to list Bedrock inference profiles, falling back to hardcoded models: UnauthorizedException: Session token not found or invalid
...
2026-07-11T17:40:38.573Z [DEBUG] [API:timing] dispatching to bedrock model=us.anthropic.claude-sonnet-5
2026-07-11T17:40:38.573Z [DEBUG] [API:auth] resolving default AWS provider chain (region: us-east-1)
2026-07-11T17:40:38.810Z [ERROR] API error (attempt 1/11): UnauthorizedException: Session token not found or invalid
Retries 3 times (each preceded by a successful credential resolve), then gives up.
Independently confirmed working outside Claude Code, same profile/region/model:
Notably it's not limited to InvokeModel — ListInferenceProfiles fails with the identical error, which points at something in Claude Code's Bedrock SDK client itself (stale/mis-signed request object) rather than a permissions or region issue.
Workaround observed: an already-running/warm Claude Code session continues to work; only fresh/cold claude process starts hit this.
macOS repro: 2.1.207 fails, 2.1.206 works — identical env and credentials
Environment:
AIUsers), credentials confirmed valid viaaws sts get-caller-identityRepro (clean env, same credentials, same machine):
The clean-env test rules out shell environment interference — the only variable is the binary version.
aws sts get-caller-identitysucceeds in both cases.Workaround: symlink
~/.local/bin/claudeto 2.1.206 (requires locking withchflags uchgto prevent Desktop app from updating it back).Confirming the same regression and fix on WSL2/Ubuntu: 2.1.207 fails with identical "Session token not found or invalid" on every cold start, pinning to 2.1.206 (via
curl -fsSL https://claude.ai/install.sh | bash -s -- 2.1.206) resolves it completely.Note for anyone using the VS Code extension: pinning the CLI binary alone isn't enough the extension have a separate Claude Code install (probably also on 2.1.207) independent of whatever's on PATH. Had to separately downgrade via Extensions panel → gear icon → "Install Another Version" to a pre-2.1.207 release. Confirmed working after both were pinned.
Also hitting this exact issue — adding a data point from a different environment, since this report is currently labeled
platform:wsland mine isn't WSL at all.Environment
AWS_PROFILE), assumed role via IAM Identity Center, Administrator-level permission setap-southeast-1global.anthropic.claude-sonnet-5[1m])CLAUDE_CODE_USE_BEDROCK=1)What's happening
Identical error —
API Error: UnauthorizedException: Session token not found or invalid— on every interactive turn in a new Claude Code session, including/doctor,/model, and plain messages. Already-running sessions started before the problem began keep working fine.What we've ruled out
aws sso login --profile <profile>— succeeds, no change to the bug~/.aws/sso/cache/and re-logged in from scratch — no changeenv | grep AWSin the shell — clean, nothing exported (auth is configured via~/.claude/settings.json'senvblock, not shell exports)/setup-bedrockfrom scratch:That last sequence feels like the cleanest repro so far: the wizard's own live Bedrock test calls succeed using the exact same credentials, seconds before an interactive message using that just-verified, just-saved config fails. That points away from anything AWS-side (expired/invalid credentials, permissions, SSO session) — those were independently proven valid by Claude Code's own code moments earlier.
Version correlation (not a clean isolated test, but another data point)
A second, separate machine (macOS) still on 2.1.206, same
AWS_PROFILE-based config shape, same region, same model — works fine. Only the Claude Code version differs (the Linux box auto-updated to 2.1.207; the Mac hasn't yet). OS also differs between the two machines, so this doesn't isolate version as the sole variable, but it's consistent with your finding that this isn't purely WSL-specific./statuson the broken instanceReproduction sequence
Happy to grab verbose/debug logs or run other diagnostics if that would help narrow it down — let me know what would be useful.
Got same issue.
Environment
Key data point — this is version-specific.
2.1.207 fails on every request with UnauthorizedException: Session token not found or invalid. Symlinking the claude binary back to 2.1.206 — same credentials, same profile, same shell/session, no re-auth — works immediately. So the credentials are valid; something in the 2.1.207 Bedrock auth path changed between 2.1.206 and 2.1.207.
This lines up with the original report ruling out SSO-token expiry (raw aws bedrock-runtime invoke-model succeeds with the same creds. Downgrading to 2.1.206 is a reliable workaround for now.
Same issue, downgrading to v2.1.202 and v2.1.206 fixes the issue. Also macOS based. Just adding another datapoint.
It seems this issue has been addressed and fixed by the latest release below. Great.
Confirming this also reproduces via a third client surface beyond the CLI/VS Code extension: Zed's external agent (
@agentclientprotocol/claude-agent-acp, the ACP wrapper Zed uses to run Claude as an external agent). This wrapper doesn't shell out to theclaudebinary — it depends directly on@anthropic-ai/claude-agent-sdk.My
~/.aws/configprofile hassso_region = eu-west-1while the Bedrockregionisus-west-2— an exact match for the root cause named in the fix note for v2.1.208 ("AWS SSO profiles whose sso_region differs from the Bedrock region").Gap for anyone using Zed's Claude agent:
@agentclientprotocol/claude-agent-acp@0.59.0(published 2026-07-13, npm latest as of this comment) still depends on@anthropic-ai/claude-agent-sdk@0.3.207— a pre-fix SDK version. So even though the CLI is fixed in 2.1.208, Zed users hit this untilclaude-agent-acpbumps its SDK dependency to0.3.208+ and cuts a new release.Workaround for Zed users in the meantime: in
settings.json, switch theclaude-acpentry underagent_serversfrom"type": "registry"to"type": "custom"with an explicit pinned command, since Zed's shared registry.json silently rewrites any version pin back to latest:Confirmed working on Claude Code v2.1.208