8000 Increasing Coverage Message Processor : From 79% to 94% by fede-dash · Pull Request #115 · strands-agents/sdk-python · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
May 27, 2025

Conversation

fede-dash
Copy link
Contributor
@fede-dash fede-dash commented May 26, 2025

phoenix_logo_small

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

  • Adding test coverage

Before
image

After
image

[Choose one of the above types of changes]

Testing

[How have you tested the change?]

  • hatch fmt --linter
  • hatch fmt --formatter
  • hatch test --all
  • Verify that the changes do not break functionality o 8000 r introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

Checklist

  • I have read the CONTRIBUTING document
  • [X ] I have added tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@fede-dash fede-dash marked this pull request as ready for review May 26, 2025 01:55
@fede-dash fede-dash requested a review from a team as a code owner May 26, 2025 01:55
@fede-dash fede-dash changed the title Increasing Coverage Message Processor : From 79% to 94% 🕊🔥 𝙿𝙷𝙾𝙴𝙽𝙸𝚇 🔥🕊- Increasing Coverage Message Processor : From 79% to 94% May 26, 2025
Copy link
Member
@awsarron awsarron left a 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.

@fede-dash
Copy link
Contributor Author

Ready for Review

@awsarron awsarron self-assigned this May 27, 2025
@awsarron awsarron changed the title 🕊🔥 𝙿𝙷𝙾𝙴𝙽𝙸𝚇 🔥🕊- Increasing Coverage Message Processor : From 79% to 94% ncreasing Coverage Message Processor : From 79% to 94% May 27, 2025
@awsarron awsarron changed the title ncreasing Coverage Message Processor : From 79% to 94% Increasing Coverage Message Processor : From 79% to 94% May 27, 2025
Copy link
Member
@awsarron awsarron left a 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.

Copy link
Member
@awsarron awsarron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fede-dash 🚀!

@awsarron awsarron merged commit c3895d4 into strands-agents:main May 27, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0