async def test_robustness_against_citation_variations(mock_streaming_agent):
    """Test agent's robustness against different citation formats and variations."""
    # Create a custom text with different citation variations
    response_text = """
    This text has different citation variations:
    1. Standard citation: [abc1234]
    2. Another citation: [def5678]
    3. Adjacent citations: [abc1234][def5678]
    4. Special characters around citation: ([abc1234]) or "[def5678]".
    """

    # Use the extract_citations function directly to see what would be detected
    citations = extract_citations(response_text)

    # There should be at least two different citation IDs
    unique_citations = set(citations)
    assert len(unique_citations) >= 2, "Should extract at least two different citation IDs"
    assert "abc1234" in unique_citations, "Should extract abc1234"
    assert "def5678" in unique_citations, "Should extract def5678"

    # Count occurrences of each citation
    counts = {}
    for cid in citations:
        counts[cid] = counts.get(cid, 0) + 1

    # Each citation should be found the correct number of times based on the text
    assert counts.get("abc1234", 0) >= 2, "abc1234 should appear at least twice"
    assert counts.get("def5678", 0) >= 2, "def5678 should appear at least twice"
Test agent's robustness against different citation formats and variations.
py/tests/unit/agent/test_agent_citations.py