-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Is your feature request related to a problem? Please describe.
I'm always frustrated when I want to specify an AWS profile or use a custom boto3.Session to create Bedrock AgentCore clients, but the code always uses the default boto3.client(...) calls and doesn’t allow passing in a session. This prevents usage of named profiles or custom session configurations.
Describe the solution you'd like
I’d like to add an optional boto3_session: boto3.Session | None = None parameter to MemoryClient.__init__. Internally:
class MemoryClient:
"""High-level Bedrock AgentCore Memory client with essential operations."""
def __init__(self, region_name: Optional[str] = None, boto3_session: boto3.Session | None = None):
session = boto3_session if boto3_session else boto3.Session()
"""Initialize the Memory client."""
self.region_name = region_name or session.region_name or "us-west-2"
self.gmcp_client = session.client("bedrock-agentcore-control", region_name=self.region_name)
self.gmdp_client = session.client("bedrock-agentcore", region_name=self.region_name)Describe alternatives you've considered
Manually patching the class in local code, but that’s tedious and not reusable.
Using environment variables (AWS_PROFILE, AWS_ACCESS_KEY_ID, etc.), but that isn't flexible for CI or code‑based configuration.
Additional context
This change would be consistent with other AWS SDK usage patterns where clients accept a session parameter. It improves flexibility and testability, especially for scenarios involving multiple AWS profiles or test harness setups.