Skip to content

Conversation

vamgan
Copy link
Contributor

@vamgan vamgan commented Sep 19, 2025

Description

Replace sequential message loading with async concurrent reading in both S3SessionManager and FileSessionManager to improve performance for long conversations. Uses asyncio.gather() with run_in_executor() to read multiple messages simultaneously while maintaining proper ordering.

Related Issues

Resolves: #874

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

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.

Replace sequential message loading with async concurrent reading in both
S3SessionManager and FileSessionManager to improve performance for long
conversations. Uses asyncio.gather() with run_in_executor() to read
multiple messages simultaneously while maintaining proper ordering.

Resolves: strands-agents#874
Copy link
Member

@Unshure Unshure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good to me! Do you have any performance data on this? Wondering if we are seeing any latency improvement for loading ~100 messages from session?

@vamgan
Copy link
Contributor Author

vamgan commented Sep 26, 2025

This all looks good to me! Do you have any performance data on this? Wondering if we are seeing any latency improvement for loading ~100 messages from session?

Yes, I had done a test during implementation and there was a major improvement in the read speed. Almost 2.5x faster for local files but s3 will have the major visible improvement.

@mehtarac mehtarac merged commit 08dc4ae into strands-agents:main Oct 2, 2025
18 of 22 checks passed
@vamgan vamgan deleted the feature/concurrent-message-reading branch October 2, 2025 21:10
pgrayy added a commit to pgrayy/sdk-python that referenced this pull request Oct 9, 2025
JackYPCOnline added a commit that referenced this pull request Oct 10, 2025
* feat: replace kwargs with invocation_state in agent APIs

* fix: handle **kwargs in stream_async.

* feat: add a unit test for the change

* Update src/strands/agent/agent.py

Co-authored-by: Nick Clegg <nac542@gmail.com>

* tool - executors - concurrent - remove no-op gather (#954)

* feat(telemetry): updated traces to match OTEL v1.37 semantic conventions (#952)

* event loop - handle model execution (#958)

* feat: implement concurrent message reading for session managers (#897)

Replace sequential message loading with async concurrent reading in both
S3SessionManager and FileSessionManager to improve performance for long
conversations. Uses asyncio.gather() with run_in_executor() to read
multiple messages simultaneously while maintaining proper ordering.

Resolves: #874

Co-authored-by: Vamil Gandhi <vamgan@amazon.com>

* hooks - before tool call event - cancel tool (#964)

* fix(telemetry): removed double serialization for events (#977)

* fix(litellm): map LiteLLM context-window errors to ContextWindowOverflowException (#994)

* feat: add more tests and adjust invocation_state dic structure

* Apply suggestion from @Unshure

Co-authored-by: Nick Clegg <nac542@gmail.com>

* fix: adjust **kwargs in multiagent primitives

---------

Co-authored-by: Nick Clegg <nac542@gmail.com>
Co-authored-by: Patrick Gray <pgrayy@amazon.com>
Co-authored-by: poshinchen <pschen@amazon.com>
Co-authored-by: Vamil Gandhi <hello@vamilgandhi.com>
Co-authored-by: Vamil Gandhi <vamgan@amazon.com>
Co-authored-by: ratish <114130421+Ratish1@users.noreply.github.com>
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.

[FEATURE] Concurrent Message read from Session Manager

3 participants