Skip to content

test: improve _fix_broken_tool_use test coverage#2029

Open
beansandroasters wants to merge 1 commit intostrands-agents:mainfrom
beansandroasters:fix/improve-broken-tool-use-test-coverage
Open

test: improve _fix_broken_tool_use test coverage#2029
beansandroasters wants to merge 1 commit intostrands-agents:mainfrom
beansandroasters:fix/improve-broken-tool-use-test-coverage

Conversation

@beansandroasters
Copy link
Copy Markdown

Summary

Improves test coverage for _fix_broken_tool_use in RepositorySessionManager, addressing test quality issues found while reviewing #2026.

  • Use copy.deepcopy in the existing last-message test — the old assertion fixed_messages == messages compared the same object to itself (since the method mutates and returns the same list), so it always passed regardless of behavior changes
  • Add test for insert()-induced last-message skip — when consecutive orphaned toolUse messages exist, insert() shifts the second into the "last message" position mid-iteration, causing it to be skipped by the index + 1 < len(messages) guard
  • Add test for single orphaned toolUse — minimal edge case where the conversation consists of just one orphaned toolUse message

Note

The two new tests intentionally fail on the current main branch — they document the existing bug that #2026 fixes. Once #2026 is merged, these tests will pass.

Test plan

Closes #2028
Related: #2025, #2026

- Use copy.deepcopy in test_fix_broken_tool_use_ignores_last_message
  so the assertion actually guards against in-place mutation
  (the old `fixed == messages` compared the same object to itself)

- Add test for consecutive orphaned toolUse messages where insert()
  during iteration shifts the second toolUse into the last position,
  causing it to be skipped by `index + 1 < len(messages)`

- Add test for single orphaned toolUse message (minimal edge case)

Closes strands-agents#2028
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.

Test: _fix_broken_tool_use tests don't guard against in-place mutation; missing coverage for insert-induced edge case

1 participant