Skip to content

fix: s3session manager bug#1915

Merged
mehtarac merged 1 commit intostrands-agents:mainfrom
mehtarac:fix_sm_bug
Mar 16, 2026
Merged

fix: s3session manager bug#1915
mehtarac merged 1 commit intostrands-agents:mainfrom
mehtarac:fix_sm_bug

Conversation

@mehtarac
Copy link
Member

Description

S3SessionManager with the default empty prefix (prefix="") produces S3 keys with a leading slash (e.g., /session_abc/agents/agent_default/agent.json). S3-compatible backends like MinIO normalize keys by stripping leading slashes on write, but the SDK reads using the original key with the leading slash. This mismatch causes read_agent() to return None, so the agent always takes the new-session branch on restore — silently discarding previous conversation history.

A related issue exists when users pass a prefix with a trailing slash (e.g., prefix="sessions/"), which produces double slashes in keys (sessions//session_abc/...).

# All of these now produce consistent, correct keys:
S3SessionManager(session_id="s1", bucket="b", prefix="")           # session_s1/...
S3SessionManager(session_id="s1", bucket="b", prefix="sessions")   # sessions/session_s1/...
S3SessionManager(session_id="s1", bucket="b", prefix="sessions/")  # sessions/session_s1/...
S3SessionManager(session_id="s1", bucket="b", prefix="/sessions/") # sessions/session_s1/...

Related Issues

#1863

Documentation PR

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mehtarac mehtarac deployed to manual-approval March 16, 2026 14:01 — with GitHub Actions Active
@mehtarac mehtarac changed the title fix s3session manager bug fix: s3session manager bug Mar 16, 2026
@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mehtarac mehtarac merged commit 39c8c19 into strands-agents:main Mar 16, 2026
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants