from deerflow.agents.memory.thread_updater import ThreadMemoryUpdater


def test_scrub_sensitive_tolerates_non_numeric_confidence():
    updater = ThreadMemoryUpdater()
    cleaned = updater._scrub_sensitive(
        {
            "user": {},
            "history": {},
            "facts": [
                {"content": "Uses React", "category": "knowledge", "confidence": "high"},
                {"content": "Uses TypeScript", "category": "knowledge", "confidence": None},
            ],
        },
        "thread-test",
    )

    assert len(cleaned["facts"]) == 2
    assert cleaned["facts"][0]["confidence"] == 0.5
    assert cleaned["facts"][1]["confidence"] == 0.5
