fix: make region optional in CodeInterpreter and code_session#523
Open
citizen204 wants to merge 2 commits into
Open
fix: make region optional in CodeInterpreter and code_session#523citizen204 wants to merge 2 commits into
citizen204 wants to merge 2 commits into
Conversation
When no region is provided, resolve it from the boto3 session using standard credential/config chain resolution (env vars, config file, EC2 instance metadata, etc.) instead of requiring an explicit string. This lets callers omit region when their environment already configures it. Fixes aws#511
jariy17
approved these changes
Jun 25, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #523 +/- ##
=======================================
Coverage ? 89.38%
=======================================
Files ? 98
Lines ? 8582
Branches ? 1273
=======================================
Hits ? 7671
Misses ? 586
Partials ? 325
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CodeInterpreter.__init__andcode_session()required an explicitregionstring, making callers responsible for extracting the region even when they already have a configured boto3 session or standard AWS environment variables in place.This PR makes
regionoptional (defaults toNone). When omitted, the region is resolved from the boto3 session via its standard chain (environment variables, config file, instance metadata, etc.). The session is created first (if not supplied), then the region is read fromsession.region_name.Existing callers passing an explicit region string are unaffected.
Fixes #511
Changes
src/bedrock_agentcore/tools/code_interpreter_client.py:CodeInterpreter.__init__: changeregion: str→region: Optional[str] = None; resolve region from session when not providedcode_session(): changeregion: str→region: Optional[str] = None