Skip to content

Conversation

@CrysisDeu
Copy link

@CrysisDeu CrysisDeu commented Nov 16, 2025

Description

This PR adds parallel reading support to S3SessionManager.list_messages() to improve performance when retrieving multiple messages from S3. The implementation uses ThreadPoolExecutor to fetch messages concurrently, significantly reducing latency for sessions with many messages.

Key Changes:

  • Added max_parallel_reads parameter to S3SessionManager.__init__() (defaults to 1 for backward compatibility)
  • Implemented parallel S3 reads using ThreadPoolExecutor in list_messages()
  • Support for both instance-level and per-call max_parallel_reads configuration
  • Maintains message order regardless of completion order
  • Handles individual message read failures gracefully without stopping the entire operation
  • Added comprehensive test coverage including edge cases and mock-based verification

Backward Compatibility:

  • Default max_parallel_reads=1 ensures sequential behavior (backward compatible)
  • Existing code continues to work without modification
  • No breaking changes to the API

Related Issues

#1164

Documentation PR

Type of Change

New feature

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

Testing Details:

  • Added 9 new test cases covering:
    • Default behavior (sequential reads)
    • Instance-level configuration
    • Per-call override functionality
    • Edge cases (few messages, many messages, pagination)
    • Mock-based verification of ThreadPoolExecutor configuration
  • All existing tests continue to pass (1520 passed, 4 skipped)
  • Verified message ordering is preserved
  • Tested error handling for individual message read failures
  • No new warnings introduced (existing warnings are pre-existing deprecation warnings)

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.

- Add max_parallel_reads parameter to S3SessionManager.__init__() - Implement parallel S3 reads using ThreadPoolExecutor in list_messages() - Support both instance-level and per-call max_parallel_reads configuration - Add comprehensive tests for parallel reading functionality - Maintain backward compatibility (default max_parallel_reads=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant