fix: prune stale tool results during session repair#2299
Conversation
|
Thanks for the fix! We hit this in production with AgentCore Memory + GLM-5 on Bedrock. Verified that the root cause matches — our workaround was to prevent corrupted history at the application layer (BeforeToolCallEvent + cancel_tool), but this SDK-level fix is the proper solution. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
d530240 to
6968cd6
Compare
|
Rebased this onto current main and revalidated the focused session-manager path. Current head is 6968cd6. Validation from strands-py: uv run pytest tests/strands/session/test_repository_session_manager.py -q --basetemp ...tmp\pytest-2299 -p no:cacheprovider: 42 passed; uv run ruff check src/strands/session/repository_session_manager.py tests/strands/session/test_repository_session_manager.py; uv run ruff format --check src/strands/session/repository_session_manager.py tests/strands/session/test_repository_session_manager.py; python -m py_compile strands-py\src\strands\session\repository_session_manager.py strands-py\tests\strands\session\test_repository_session_manager.py; git diff --check origin/main...HEAD. |
|
Closing in favor of #2320 |
Summary
toolResultblocks while repairing restored session historiestoolUseblocksFixes #2296
Tests
.venv\Scripts\python.exe -m pytest tests\strands\session\test_repository_session_manager.py -q -k "fix_broken_tool_use".venv\Scripts\python.exe -m pytest tests\strands\session\test_repository_session_manager.py -q$env:RUFF_CACHE_DIR='.tmp\ruff-cache'; .venv\Scripts\python.exe -m ruff check src\strands\session\repository_session_manager.py tests\strands\session\test_repository_session_manager.py$env:RUFF_CACHE_DIR='.tmp\ruff-cache'; .venv\Scripts\python.exe -m ruff format --check src\strands\session\repository_session_manager.py tests\strands\session\test_repository_session_manager.py.venv\Scripts\python.exe -m py_compile src\strands\session\repository_session_manager.py tests\strands\session\test_repository_session_manager.pygit diff --check