Skip to content

fix: discard orphaned session tool results#2398

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

fix: discard orphaned session tool results#2398
he-yufeng wants to merge 1 commit into
strands-agents:mainfrom
he-yufeng:fix/session-manager-tool-result-repair

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Fixes #2296.

Summary

  • make RepositorySessionManager._fix_broken_tool_use() drop toolResult blocks that do not match the immediately preceding toolUse
  • keep existing behavior for filling missing toolResult blocks
  • avoid leaving an empty user message when a message contained only stale tool results
  • add regressions for stale-only and stale-plus-valid tool result histories

To verify

  • python -m pytest tests/strands/session/test_repository_session_manager.py -q
  • python -m ruff check src/strands/session/repository_session_manager.py tests/strands/session/test_repository_session_manager.py
  • python -m ruff format --check src/strands/session/repository_session_manager.py tests/strands/session/test_repository_session_manager.py

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