fix(memory): pass boto3 session to MemoryClient in AgentCoreMemorySessionManager - #682
Open
avneetbansal-aws wants to merge 1 commit into
Open
avneetbansal-aws wants to merge 1 commit into
avneetbansal-aws wants to merge 1 commit into
Conversation
…sionManager AgentCoreMemorySessionManager.__init__ built its MemoryClient without a boto3 session (MemoryClient then created its clients from a default session), before overwriting the clients from the user-provided session. This discarded the session on the MemoryClient itself. Compute the resolved session first and pass it into MemoryClient(boto3_session=...) so it uses the correct session from the start; the subsequent strands-agents user-agent override still applies. Fixes aws#681. Signed-off-by: avneetbansal-aws <284363899+avneetbansal-aws@users.noreply.github.com>
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
avneetbansal-aws
requested a deployment
to
manual-approval
September 28, 2026 03:59 — with
GitHub Actions
Waiting
This branch is waiting to be deployed
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.
Fixes #681.
Problem
`AgentCoreMemorySessionManager.init` constructed its `MemoryClient` without a boto3 session:
```python
self.memory_client = MemoryClient(region_name=region_name) # no session
session = boto_session or boto3.Session(region_name=region_name)
```
Because no session is passed, `MemoryClient.init` builds its `gmcp_client`/`gmdp_client` from a default `boto3.Session()` — so a user-provided `boto_session` (named profile, custom credentials, etc.) is silently discarded on the `MemoryClient` itself. The manager then overwrites those two clients from the correct session, but the `MemoryClient` was still initialized against the wrong one.
Fix
Resolve the session first, then pass it into `MemoryClient`, which already accepts `boto3_session`:
```python
session = boto_session or boto3.Session(region_name=region_name)
self.memory_client = MemoryClient(region_name=region_name, boto3_session=session)
```
The existing `strands-agents` user-agent / `boto_client_config` override that follows is unchanged, so behavior for the overridden clients is identical — the fix just ensures the `MemoryClient` uses the correct session from the start.
Tests