async def test_citation_tracker_during_streaming(mock_streaming_agent):
    """Test that CitationTracker correctly tracks processed citations during streaming."""
    # We need to patch the is_new_span method to verify it's being used correctly
    # Use autospec=True to ensure the method signature is preserved
    with patch('core.utils.CitationTracker.is_new_span', autospec=True) as mock_is_new_span:
        # Configure the mock to return True so citations will be processed
        mock_is_new_span.return_value = True

        messages = [Message(role="user", content="Test query")]

        # Run the agent
        stream = mock_streaming_agent.arun(messages=messages)
        output = await collect_stream_output(stream)

        # Verify that CitationTracker.is_new_span method was called
        assert mock_is_new_span.call_count > 0, "is_new_span should be called to track citation spans"
Test that CitationTracker correctly tracks processed citations during streaming.
py/tests/unit/agent/test_agent_citations.py