Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/bedrock_agentcore/memory/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,32 @@ class MemoryClient:
"list_memory_strategies",
}

def __init__(self, region_name: Optional[str] = None, integration_source: Optional[str] = None):
"""Initialize the Memory client."""
self.region_name = region_name or boto3.Session().region_name or "us-west-2"
def __init__(
self,
region_name: Optional[str] = None,
integration_source: Optional[str] = None,
boto3_session: Optional[boto3.Session] = None,
):
"""Initialize the Memory client.

Args:
region_name: AWS region name. If not provided, uses the session's region or "us-west-2".
integration_source: Optional integration source for user-agent telemetry.
boto3_session: Optional boto3 Session to use. If not provided, a default session
is created. Useful for named profiles or custom credentials.
"""
session = boto3_session if boto3_session else boto3.Session()
self.region_name = region_name or session.region_name or "us-west-2"
self.integration_source = integration_source

# Build config with user-agent for telemetry
user_agent_extra = build_user_agent_suffix(integration_source)
client_config = Config(user_agent_extra=user_agent_extra)

self.gmcp_client = boto3.client("bedrock-agentcore-control", region_name=self.region_name, config=client_config)
self.gmdp_client = boto3.client("bedrock-agentcore", region_name=self.region_name, config=client_config)
self.gmcp_client = session.client(
"bedrock-agentcore-control", region_name=self.region_name, config=client_config
)
self.gmdp_client = session.client("bedrock-agentcore", region_name=self.region_name, config=client_config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to inject client configuration as well?


logger.info(
"Initialized MemoryClient for control plane: %s, data plane: %s",
Expand Down
Loading
Loading