claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Bedrock env vars ignored in home directory

Open clayallsopp opened this issue 6 months ago • 3 comments

Environment

  • Platform (select one):
    • [ ] Anthropic API
    • [x] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version:
  • Operating System:
  • Terminal:

Bug Description

When running claude in the home directory with the ANTHROPIC_* and CLAUDE_CODE_USE_BEDROCK variables set, it seems like Bedrock is still used for queries, but it is no longer respecting the ANTHROPIC_MODEL parameters:

╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code!                         │
│                                                   │
│   /help for help, /status for your current setup  │
│                                                   │
│   cwd: /Users/callsopp                            │
╰───────────────────────────────────────────────────╯


> Hello
  ⎿ API Error: 403 {"Message":"User: xxx/callsopp is not authorized
    to perform: bedrock:InvokeModel on resource:
    arn:xxx:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0 because no session
    policy allows the bedrock:InvokeModel action"}

That inference profile is the default Bedrock inference profile, which my AWS permissions do not have access to. My ANTHROPIC_MODEL is set to the proper inference profile, but it isn't being used. This only seems to happen when my cwd is my home directory (which isn't advised but some teammates have reasons for doing this, such as on VMs).

Steps to Reproduce

  1. Set Bedrock env vars
  2. Try to run a query
  3. Observe the wrong ANTHROPIC_MODEL is used (should be possible to repro by setting a fake ANTHROPIC_MODEL and then still seeing the default profile used)

Expected Behavior

The ANTHROPIC_MODEL should be used

Actual Behavior

The default Bedrock model/inference profile is used

Additional Context

clayallsopp avatar Jun 04 '25 17:06 clayallsopp

FYI, I'm no longer suffering this problem in 1.0.11. Something between 0.2.125 and now fixed it for me.

mark-richardson-ncino avatar Jun 05 '25 02:06 mark-richardson-ncino

  • The latest version does indeed fix the home directory issue
  • But, the latest version also seems to regress showing the ANTHROPIC_MODEL (which, in our case, is a non-default inference profile) in the OVERRIDES section in the intro (which is/was very helpful to debug broken setups). If I do /model, it looks like it is still set / everything works, but the lack of the output in the intro isn't great

clayallsopp avatar Jun 05 '25 14:06 clayallsopp

  • But, the latest version also seems to regress showing the ANTHROPIC_MODEL in the OVERRIDES section in the intro

I can second this.

mark-richardson-ncino avatar Jun 05 '25 23:06 mark-richardson-ncino

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 16 '25 14:08 github-actions[bot]