Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import logging
import os
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any, Optional

Expand Down Expand Up @@ -64,6 +65,7 @@ def __init__(
Defaults to None.
**kwargs (Any): Additional keyword arguments.
"""
region_name = region_name or os.environ.get("AWS_REGION")
self.config = agentcore_memory_config
self.memory_client = MemoryClient(region_name=region_name)
session = boto_session or boto3.Session(region_name=region_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ def test_init_basic(self, agentcore_config):
assert manager.memory_client == mock_client
mock_client_class.assert_called_once_with(region_name=None)

def test_init_with_aws_region_env_var(self, agentcore_config):
"""Test initialization with AWS_REGION environment variable."""
with patch("bedrock_agentcore.memory.integrations.strands.session_manager.MemoryClient") as mock_client_class:
mock_client = Mock()
mock_client_class.return_value = mock_client

with patch("boto3.Session") as mock_boto_session:
mock_session = Mock()
mock_session.client.return_value = Mock()
mock_boto_session.return_value = mock_session

with patch(
"strands.session.repository_session_manager.RepositorySessionManager.__init__", return_value=None
):
with patch.dict("os.environ", {"AWS_REGION": "us-east-1"}):
AgentCoreMemorySessionManager(agentcore_config)
mock_client_class.assert_called_once_with(region_name="us-east-1")

def test_events_to_messages(self, session_manager):
"""Test converting Bedrock events to SessionMessages."""
events = [
Expand Down
Loading