Published April 26, 2026 | Version v1
Preprint Open

Cognitive Immunity: Anti-Fragile Reasoning through Bio-Inspired Failure Learning in AI Agents

Authors/Creators

Description

AI agents make mistakes — but unlike biological organisms, they do not learn from them. Current approaches (Self-Refine, Reflexion) correct errors within a session but retain no persistent memory of failure patterns across sessions. We introduce Cognitive Immunity, a bio-inspired mechanism that transforms AI agents from fragile (brittle under novel errors) to anti-fragile (strengthened by adversity). The system maintains an evolving antibody store: upon encountering a reasoning failure, B-Cell extractors identify the failure fingerprint (antigen) and generate avoidance strategies (antibodies). At inference time, T-Cell interceptors match incoming queries against known failure patterns, injecting preventive context before reasoning begins. Antibodies decay exponentially but are reinforced upon re-encounter, implementing an adaptive immune memory.

We formalize Cognitive Immunity within a PAC-learning framework, proving: (1) a sample complexity bound for (ε,δ)-immunity; (2) the steady-state antibody population converges to r/λ under decay-reinforcement dynamics; (3) antibodies generalize to similar failures within an embedding ball of radius ρ; (4) multi-agent herd immunity achieves O(log M / M) collective failure rate.

We evaluate on WisdomBench, a longitudinal benchmark measuring agent wisdom acquisition through 20 tasks × 5 rounds × 3 seeds on DeepSeek-v4-flash (N=1,200 evaluations). Cognitive Immunity achieves the lowest repeat failure rate (RFR = 0.650) — 15% lower than the No Memory baseline (RFR = 0.764). On sycophancy tasks, No Memory shows degradation (Δ = -0.53), while Cognitive Immunity maintains stability (Δ = 0.00), demonstrating persistent immunity against adversarial pressure erosion.

Files

Cognitive Immunity Anti-Fragile Reasoning through Bio-Inspired Failure Learning in AI Agents.pdf