Skip to content

feat(session): add put_object_kwargs support to S3SessionManager#2328

Open
gauravSsinha wants to merge 1 commit into
strands-agents:mainfrom
gauravSsinha:feat/s3-session-manager-put-object-kwargs
Open

feat(session): add put_object_kwargs support to S3SessionManager#2328
gauravSsinha wants to merge 1 commit into
strands-agents:mainfrom
gauravSsinha:feat/s3-session-manager-put-object-kwargs

Conversation

@gauravSsinha
Copy link
Copy Markdown

Description

Adds support for passing custom parameters to S3 put_object calls in S3SessionManager. This enables configuring server-side encryption (SSE-KMS), storage class, tagging, and other S3 PutObject parameters when storing session data.

Changes

  • Added put_object_kwargs extraction from **kwargs in S3SessionManager.__init__()
  • Updated _write_s3_object() to spread put_object_kwargs into all put_object calls
  • Added 4 unit tests covering initialization and S3 write behavior

Usage

from strands.session import S3SessionManager

session_manager = S3SessionManager(
    session_id="my-session",
    bucket="my-bucket",
    put_object_kwargs={
        "ServerSideEncryption": "aws:kms",
        "SSEKMSKeyId": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
    }
)

Design Decision

Following the maintainer's guidance in #1247, put_object_kwargs is passed via **kwargs and stored as an instance variable. This approach:

  • Is backwards-compatible (no signature change)
  • Follows the existing extensibility pattern (**kwargs already accepted)
  • Scales with the S3 PutObject API without needing individual parameters

Testing

  • All 50 existing S3SessionManager tests pass
  • 4 new tests added covering:
    • Initialization with put_object_kwargs
    • Default empty dict when not provided
    • Successful S3 writes with encryption params
    • Successful S3 writes with StorageClass param

Closes #1247

Add support for passing custom parameters to S3 put_object calls in
S3SessionManager. This enables configuring server-side encryption
(SSE-KMS), storage class, tagging, and other S3 PutObject parameters
when storing session data.

The put_object_kwargs parameter is passed via **kwargs and stored as
an instance variable, then spread into all put_object calls. This
approach is backwards-compatible and follows the maintainer's
suggested pattern.

Example usage:
  session_manager = S3SessionManager(
      session_id='my-session',
      bucket='my-bucket',
      put_object_kwargs={
          'ServerSideEncryption': 'aws:kms',
          'SSEKMSKeyId': 'arn:aws:kms:us-east-1:123456789012:key/...'
      }
  )

Closes strands-agents#1247

Signed-off-by: Gaurav Kumar Sinha <gaurav@substrai.dev>
@yonib05 yonib05 added area-persistence Session management or checkpointing python Pull requests that update python code enhancement New feature or request labels May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-persistence Session management or checkpointing enhancement New feature or request python Pull requests that update python code size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add support for passing custom parameters to S3 put_object calls in S3SessionManager

2 participants