Skip to content

Conversation

@afarntrog
Copy link
Contributor

@afarntrog afarntrog commented Sep 4, 2025

Description of changes:

This pull request introduces a new integration with Strands and Amazon Bedrock AgentCore Memory, providing support to use AgentCore Memory as a Session Manager with Strands agents.

Bedrock AgentCore Memory Integration:

  • Added AgentCoreMemoryConfig and RetrievalConfig Pydantic models to configure session management and retrieval strategies for Bedrock AgentCore Memory integration. (src/bedrock_agentcore/memory/integrations/config.py)
  • Implemented BedrockConverter utility class for converting between Strands and Bedrock AgentCore Memory message/event formats, including support for tool and image payloads. (src/bedrock_agentcore/memory/integrations/bedrock_converter.py)
  • Declared the package as PEP 561 type-checked by adding an empty py.typed marker file. (src/bedrock_agentcore/memory/integrations/py.typed)

Documentation and Examples:

  • Added a comprehensive README.md with quick setup instructions, code examples, and best practices for using Strands with Bedrock AgentCore Memory (STM and LTM). (src/bedrock_agentcore/memory/integrations/README.md)

Testing and Validation:

  • Added unit tests. (tests/bedrock_agentcore/memory/integrations/)
  • Added an integration tests. (tests_integ/memory/integrations/)

Dependency Management:

  • Added an optional dependency group for strands-agents in pyproject.toml to simplify installation for users who need this integration. (pyproject.toml)

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

- Add AgentCoreMemorySessionManager for persistent conversation storage
- Implement bedrock_converter for message format transformation
- Add configuration management for memory settings
- Include comprehensive unit and integration tests
- Add strands-agents optional dependency in pyproject.toml
- Provide documentation and examples for STM/LTM support
bergjaak
bergjaak previously approved these changes Sep 4, 2025
Copy link
Contributor

@jona62 jona62 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@sundargthb sundargthb left a comment

Choose a reason for hiding this comment

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

Can this live under a "strands" folder under integrations ? in case there are future integrations

@afarntrog afarntrog requested a review from sundargthb September 5, 2025 18:19
kandoin
kandoin previously approved these changes Sep 5, 2025
@sundargthb
Copy link
Contributor

sundargthb commented Sep 5, 2025

@afarntrog can you please run "uv run pre-commit run --all-files" and make sure we pass the test coverage

@afarntrog
Copy link
Contributor Author

@afarntrog can you please run "uv run pre-commit run --all-files" and make sure we pass the test coverage

done

╰─± uv run pre-commit run --all-files
uv-lock..................................................................Passed
ruff (legacy alias)......................................................Passed
ruff format..............................................................Passed
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check toml...............................................................Passed
check json...........................................(no files to check)Skipped
check for merge conflicts................................................Passed
check for added large files..............................................Passed
debug statements (python)................................................Passed
bandit...................................................................Passed
pytest with coverage.....................................................Passed

@codecov-commenter
Copy link

codecov-commenter commented Sep 5, 2025

Codecov Report

❌ Patch coverage is 89.20188% with 23 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@3093768). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ore/memory/integrations/strands/session_manager.py 87.27% 11 Missing and 10 partials ⚠️
...e/memory/integrations/strands/bedrock_converter.py 94.44% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #65   +/-   ##
=======================================
  Coverage        ?   88.63%           
=======================================
  Files           ?       20           
  Lines           ?     1848           
  Branches        ?      276           
=======================================
  Hits            ?     1638           
  Misses          ?      104           
  Partials        ?      106           
Flag Coverage Δ
unittests 88.63% <89.20%> (?)

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
Copy link
Contributor

bergjaak commented Sep 5, 2025

@afarntrog the integ tests for https://github.com/aws/bedrock-agentcore-sdk-python/actions/runs/17503488121/job/49722240114?pr=65 currently only run if you make the PR as a branch of the repo. You can run them locally by looking at the workflow step for https://github.com/aws/bedrock-agentcore-sdk-python/actions/runs/17503488121/job/49722240114?pr=65 and then just attaching the results here

@afarntrog
Copy link
Contributor Author

Ran the new integration tests locally with the following passing output:

╰─± python -m pytest tests_integ/memory/integrations/test_session_manager.py -v
==================================================== test session starts ====================================================
platform darwin -- Python 3.10.18, pytest-8.4.1, pluggy-1.6.0 -- /Volumes/workplace/strandsorg/bedrock-agentcore-sdk-python/.venv/bin/python
cachedir: .pytest_cache
rootdir: /Volumes/workplace/strandsorg/bedrock-agentcore-sdk-python
configfile: pyproject.toml
plugins: anyio-4.9.0, asyncio-1.1.0, cov-6.2.1
asyncio: mode=strict, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 6 items                                                                                                           

tests_integ/memory/integrations/test_session_manager.py::TestAgentCoreMemorySessionManager::test_session_manager_initialization PASSED [ 16%]
tests_integ/memory/integrations/test_session_manager.py::TestAgentCoreMemorySessionManager::test_agent_with_session_manager PASSED [ 33%]
tests_integ/memory/integrations/test_session_manager.py::TestAgentCoreMemorySessionManager::test_conversation_persistence PASSED [ 50%]
tests_integ/memory/integrations/test_session_manager.py::TestAgentCoreMemorySessionManager::test_session_manager_with_retrieval_config_adds_context PASSED [ 66%]
tests_integ/memory/integrations/test_session_manager.py::TestAgentCoreMemorySessionManager::test_multiple_namespace_retrieval_config PASSED [ 83%]
tests_integ/memory/integrations/test_session_manager.py::TestAgentCoreMemorySessionManager::test_session_manager_error_handling PASSED [100%]
===================================================== warnings summary ======================================================
tests_integ/memory/integrations/test_session_manager.py:25
  /Volumes/workplace/strandsorg/bedrock-agentcore-sdk-python/tests_integ/memory/integrations/test_session_manager.py:25: PytestUnknownMarkWarning: Unknown pytest.mark.integration - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.integration

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================= 6 passed, 1 warning in 411.66s (0:06:51) ==========================================

@bergjaak bergjaak merged commit 7f866d9 into aws:main Sep 5, 2025
15 of 16 checks passed
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.

6 participants