aider icon indicating copy to clipboard operation
aider copied to clipboard

Inconsistent behavior when invoking Bedrock LLMs

Open abuakeel opened this issue 1 year ago • 10 comments

Issue

Hello. When accessing the cross region inference models in AWS Bedrock i get inconsistent operations depending on the model invoked. When using any model but us.anthropic.claude-3-opus-20240229-v1:0 aider returns an error after i submit the first prompt.

Error message: litellm.APIConnectionError: BedrockException - b'{"message":"You don't have access to the model with the specified model ID."}'

For context:

  • AWS SSO auth (confirmed auth does work).

  • I have access to all models called in bedrock (confirmed with CLI invocation).

  • analytics log for working model (claude-3-opus) - {"event": "message_send", "properties": {"main_model": "us.anthropic.claude-3-opus-20240229-v1:0", "weak_model": "us.anthropic.claude-3-opus-20240229-v1:0", "editor_model": "us.anthropic.claude-3-opus-20240229-v1:0", "edit_format": "diff", "prompt_tokens": 3147, "completion_tokens": 332, "total_tokens": 3479, "cost": 0.072105, "total_cost": 0.173115}, "user_id": "[REMOVED]", "time": 1742560429}

  • analytics log for nonfunctional example (claude-3-7-sonnet) - {"event": "cli session", "properties": {"main_model": "us.anthropic.claude-3-7-sonnet-20250219-v1:0", "weak_model": "us.anthropic.claude-3-7-sonnet-20250219-v1:0", "editor_model": "us.anthropic.claude-3-7-sonnet-20250219-v1:0", "edit_format": "whole"}, "user_id": "[REMOVED]", "time": 1742560027}

I noticed that the edit format is different between the two (whole vs diff). I added an --edit-format diff flag to the command prompt and the 3-7 model maintained the "whole" setting (I am not sure if that is expected behavior). I also changed Opus to "whole" and it functioned properly so that probably is not related to the initial problem raised.

Version and model info

aider --version = aider 0.77.1 us.anthropic.claude-3-opus-20240229-v1:0 us.anthropic.claude-3-7-sonnet-20250219-v1:0

terminal invocation:

aider --model us.anthropic.claude-3-7-sonnet-20250219-v1:0

aider --model us.anthropic.claude-3-opus-20240229-v1:0

abuakeel avatar Mar 21 '25 12:03 abuakeel

Further comments. I checked the Cloudtrail logs for my AWS account. The opus calls are hitting the AWS endpoint. None of the 3.7 Sonnet calls are. So the calls are failing before they reach AWS.

abuakeel avatar Mar 21 '25 18:03 abuakeel

Having the same issue with Claude 3.5 v1 in Paris region. AWS CLI says I have access with my credentials, but errors out with Aider. This probably is an issue with the Aider dependency LiteLLM. Maybe should bump up the version? They recently had a lot of fixes for Bedrock specifically.

arvo95 avatar Mar 23 '25 18:03 arvo95

Okay, it seems like I've figured out what the problem is. The LiteLLM usage slightly differs from the information in the Aider docs. To determine your region, it uses AWS_REGION_NAME environ and not AWS_DEFAULT_REGION - the one that AWS CLI actually uses. So by default LiteLLM sends the request to us-west-2 without explicitly stating so, unless one runs it directly and you can see it in the error trace. So if you do not have the model access in us-west-2, then you get this error. So to fix this issue, just set AWS_REGION_NAME environment variable to the region that you want to use.

arvo95 avatar Mar 23 '25 19:03 arvo95

I ended up identifying the issue. It wasn't the AWS_REGION_NAME env variable export, but it was related. Since I am using the multi-region endpoints, it does mean i have to have access to the models in all AWS regions in the US that support the endpoint. Users must have access to a model (say Sonnet 3.7) in us-east-1, us-east-2, and us-west-2.

It is a bit counterintuitive, and I don't see this behavior within the CLI. So maybe the pinned LiteLLM version used in Aider is causing these issues as you have said arvo95.

abuakeel avatar Mar 24 '25 00:03 abuakeel

Sorry, can someone confirm if we need to make changes to the aider docs for Bedrock? And if so, what change is needed?

https://aider.chat/docs/llms/bedrock.html

paul-gauthier avatar Mar 30 '25 21:03 paul-gauthier

In this paragraph: https://aider.chat/docs/llms/bedrock.html#select-a-model-from-amazon-bedrock I would add:

"If you intend to use a multi-region endpoint, ensure that it has been enabled in all the regions a call could be routed to. For a 'us' endpoint this would be us-east-1, us-east-2, and us-west-2."

abuakeel avatar Mar 31 '25 14:03 abuakeel

I'm labeling this issue as stale because it has been open for 2 weeks with no activity. If there are no additional comments, I will close it in 7 days.

Note: A bot script made these updates to the issue.

github-actions[bot] avatar Apr 15 '25 00:04 github-actions[bot]

I'm closing this issue because it has been stalled for 3 weeks with no activity. Feel free to add a comment here and we can re-open it. Or feel free to file a new issue at any time.

Note: A bot script made these updates to the issue.

github-actions[bot] avatar Apr 22 '25 00:04 github-actions[bot]

I also get this problem, I have my region set correctly in .env : AWS_REGION=us-east-1

Everything works, then I get the llm errors : litellm.APIConnectionError: BedrockException - {"message":"You don't have access to the model with the specified model ID."} Retrying in 32.0 seconds...

flatmax avatar Apr 24 '25 07:04 flatmax

I also get this problem, I have my region set correctly in .env : AWS_REGION=us-east-1

Everything works, then I get the llm errors : litellm.APIConnectionError: BedrockException - {"message":"You don't have access to the model with the specified model ID."} Retrying in 32.0 seconds...

I solved it by running AWS_REGION=us-east-1 aider --model <multi-region-endpoint>.