async def test_citation_sanitization():
    """Test that citation IDs are properly sanitized before processing."""
    # Since extract_citations uses a strict regex pattern [A-Za-z0-9]{7,8},
    # we should test with valid citation formats
    text = "Citation with surrounding text[abc1234]and [def5678]with no spaces."

    # Extract citations
    citations = extract_citations(text)

    # Check if citations are properly extracted
    assert "abc1234" in citations, "Citation abc1234 should be extracted"
    assert "def5678" in citations, "Citation def5678 should be extracted"

    # Test with spaces - these should NOT be extracted based on the implementation
    text_with_spaces = "Citation with [abc1234 ] and [ def5678] spaces."
    citations_with_spaces = extract_citations(text_with_spaces)

    # The current implementation doesn't extract citations with spaces inside the brackets
    assert len(citations_with_spaces) == 0 or "abc1234" not in citations_with_spaces, "Citations with spaces should not be extracted with current implementation"
Test that citation IDs are properly sanitized before processing.
py/tests/unit/agent/test_agent_citations_old.py