[#119] Add agent overlap analysis script for Python#327
Closed
pierrehanne wants to merge 1 commit into
Closed
Conversation
brnaba-aws
reviewed
May 28, 2025
brnaba-aws
left a comment
Collaborator
There was a problem hiding this comment.
please also add in the documentation the python version. Thanks
| import pytest | ||
| from agent_squad.agent_overlap_analyzer import AgentOverlapAnalyzer, OverlapResult, UniquenessScore | ||
| from agent_squad.utils.logger import Logger | ||
|
|
Collaborator
There was a problem hiding this comment.
from unittest.mock import patch| analyzer = AgentOverlapAnalyzer(single_agent) | ||
| with pytest.raises(ValueError, match="Agent Overlap Analysis requires at least two agents."): | ||
| analyzer.analyze_overlap() | ||
|
|
Collaborator
There was a problem hiding this comment.
Add another test to have 100% coverage and also checking on the log:
def test_analyze_overlap_logging_with_mock(sample_agents):
"""Test that analyze_overlap calls Logger.info with expected messages"""
with patch.object(Logger, 'info') as mock_logger:
analyzer = AgentOverlapAnalyzer(sample_agents)
analyzer.analyze_overlap()
# Verify Logger.info was called
assert mock_logger.call_count > 0
# Get all the logged messages
logged_messages = [call.args[0] for call in mock_logger.call_args_list]
# Verify specific log messages are present
assert "Pairwise Overlap Results:" in logged_messages
assert "_________________________\n" in logged_messages
assert "Uniqueness Scores:" in logged_messages
assert "_________________\n" in logged_messages
# Verify agent pair combinations are logged
agent_pairs_found = []
for message in logged_messages:
if " - " in message and "Overlap Percentage" in message:
agent_pairs_found.append(message)
# Should have 3 pairs: AgentA-AgentB, AgentA-AgentC, AgentB-AgentC
assert len(agent_pairs_found) == 3
# Verify uniqueness scores are logged for each agent
uniqueness_messages = [msg for msg in logged_messages if "Agent:" in msg and "Uniqueness Score:" in msg]
assert len(uniqueness_messages) == 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement AgentOverlapAnalyzer in Python [Issue #119] @cornelcroi
Adding Unit tests to verify: