async def test_citation_tracking_state_persistence():
    """Test that the CitationTracker correctly maintains state across multiple calls."""
    tracker = CitationTracker()

    # Record some initial spans
    tracker.is_new_span("abc1234", (10, 18))
    tracker.is_new_span("def5678", (30, 38))

    # Check if spans are correctly stored
    all_spans = tracker.get_all_spans()
    assert "abc1234" in all_spans, "Citation abc1234 should be tracked"
    assert "def5678" in all_spans, "Citation def5678 should be tracked"
    assert all_spans["abc1234"] == [(10, 18)], "Span positions should match"

    # Add another span for an existing citation
    tracker.is_new_span("abc1234", (50, 58))

    # Check if the new span was added
    all_spans = tracker.get_all_spans()
    assert len(all_spans["abc1234"]) == 2, "Citation abc1234 should have 2 spans"
    assert (50, 58) in all_spans["abc1234"], "New span should be added"
Test that the CitationTracker correctly maintains state across multiple calls.
py/tests/unit/agent/test_agent_citations.py