Skip to content

Conversation

jona62
Copy link
Contributor

@jona62 jona62 commented Sep 28, 2025

Issue #, if available: N/A

Description of changes:

This PR enhances the MemorySessionManager with improved boto3 client configuration support and timestamp precision handling:

Commit 1: Add support for boto_client_config

  • Added boto_client_config parameter to MemorySessionManager constructor to allow custom botocore configuration
  • Implemented intelligent config merging that preserves user-provided settings while adding SDK user agent
  • Enhanced user agent handling to append "bedrock-agentcore-sdk" to existing user agents or set as default
  • Added comprehensive test coverage (331 new lines) including tests for:
    • Custom retry configurations
    • Connection pool settings
    • User agent preservation and merging
    • Integration with boto3 sessions
    • Edge cases and parameter validation

Commit 2: Override timestamp serializer for microsecond granularity

  • Implemented custom timestamp serialization to preserve microsecond precision when sending datetime objects to AgentCore Memory service
  • Refactored MemorySessionManager initialization into modular helper methods:
    • _validate_and_resolve_region() for region consistency validation
    • _build_client_config() for boto3 client configuration building
    • _configure_timestamp_serialization() for timestamp precision setup
  • Fixed region validation logic to properly handle session region types
  • Improved code organization and maintainability through method extraction

These changes provide:

  1. Enhanced Configuration Flexibility: Users can now customize boto3 client behavior (retries, timeouts, connection pools) while maintaining SDK functionality
  2. Improved Timestamp Precision: Datetime objects now preserve microsecond precision in API calls, critical for time-sensitive memory operations
  3. Better Code Structure: Modular initialization methods improve readability and testability
  4. Comprehensive Testing: Extensive test coverage ensures reliability across various configuration scenarios

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

@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2025

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@72e37df). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/bedrock_agentcore/memory/session.py 92.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #98   +/-   ##
=======================================
  Coverage        ?   89.37%           
=======================================
  Files           ?       23           
  Lines           ?     2306           
  Branches        ?      331           
=======================================
  Hits            ?     2061           
  Misses          ?      140           
  Partials        ?      105           
Flag Coverage Δ
unittests 89.37% <92.59%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

bergjaak
bergjaak previously approved these changes Sep 28, 2025
bergjaak
bergjaak previously approved these changes Sep 28, 2025
@jona62 jona62 merged commit 107fd53 into aws:main Sep 28, 2025
16 of 17 checks passed
@jona62 jona62 deleted the feature/boto_client_config branch September 28, 2025 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants