-
Notifications
You must be signed in to change notification settings - Fork 153
Increasing Coverage Message Processor : From 79% to 94% #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @fede-dash, this is great! A couple of small comments and then we'll merge this.
Ready for Review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @fede-dash.
Small one: when running hatch fmt
I get some reformatting:
cmd [1] | ruff check --fix
All checks passed!
cmd [2] | ruff format
1 file reformatted, 100 files left unchanged
Will merge after this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @fede-dash 🚀!
Description
🧪 Test Suite Overview for message_processor
This test module provides coverage for key utility functions in message_processor.py under strands.event_loop, specifically validating behavior related to message sanitization and correction in tool use scenarios. The tests are structured with pytest and include parameterized inputs for robustness.
✅ test_clean_orphaned_empty_tool_uses
Tests the function clean_orphaned_empty_tool_uses, which removes or replaces toolUse messages that:
• Have empty input
• Do not have a matching toolResult
This ensures the message history doesn’t contain stale or incomplete tool use entries. The test checks both whether the cleanup happened and what the cleaned messages look like.
🔍 test_find_last_message_with_tool_results
Validates find_last_message_with_tool_results, which scans a message list to find the last occurrence of a toolResult. This is useful for indexing or pruning based on tool result placement.
✂️ test_truncate_tool_results
Covers truncate_tool_results, which modifies a specific message to mark its toolResult as errored (e.g., when the result is too large). The function updates the content and returns a flag indicating whether the modification occurred.
Each test ensures:
• Correct handling of edge cases (empty inputs, invalid indexes)
• No side effects on input data (using deepcopy)
• Expected message transformations or detection logic
Type of Change
Before

After

[Choose one of the above types of changes]
Testing
[How have you tested the change?]
hatch fmt --linter
hatch fmt --formatter
hatch test --all
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.