Skip to content

fix: prune stale tool results during session repair#2299

Open
he-yufeng wants to merge 1 commit into
strands-agents:mainfrom
he-yufeng:fix/session-tool-result-repair
Open

fix: prune stale tool results during session repair#2299
he-yufeng wants to merge 1 commit into
strands-agents:mainfrom
he-yufeng:fix/session-tool-result-repair

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • prune orphaned or duplicate toolResult blocks while repairing restored session histories
  • keep the existing matching results and add only the missing interruption results, so the next user message matches the preceding assistant toolUse blocks
  • add a regression test for mixed duplicate/stale/missing tool-result history

Fixes #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.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: repository_session_manager adds incorrect number of toolResult blocks when fixing orphaned toolUse

1 participant