Skip to content

Enhancement: support custom boto3.Session in MemoryClient #44

Closed

Description

@Ryo-Suzukii

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.

Activity

  1. added
    enhancement
    memory
    on Aug 8, 2025
  2. jona62 commented on Oct 2, 2025

    @jona62
    Contributor

    The new MemorySessionManager now supports passing custom boto3.Session and BotocoreConfig.

    To get this new construct, run the following command

    pip install --upgrade bedrock-agentcore
  3. added a commit that references this issue on Mar 12, 2026
    2288ca9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmemory

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions