DEV Community

NILE GREEN
NILE GREEN

Posted on

How I Built Collapse Detection for Persistent AI Agents

F_total is your model's prediction error energy — cross-entropy loss
for LLMs, TD error for RL agents.

F_survival is the minimum energy
required to maintain operational integrity.

k(s) is a sensitivity
constant that grows with runtime.

Quick Start

from tci_calculator import TCICalculator
from k_estimator import KEstimator

k_est = KEstimator(window_size=100)
tci   = TCICalculator(f_survival=0.35)

f_total    = 0.72
complexity = 0.61

k      = k_est.update(f_total - 0.35, complexity)
result = tci.compute(f_total, k)

print(result)
# TCIResult(tci=0.74, grade='A', stage='Generativity', surplus=0.37)
Enter fullscreen mode Exit fullscreen mode

What the Grades Mean

Grade TCI Range Stage Action
A ≥ 0.60 Generativity Raise exploration
B 0.40–0.60 Learning Maintain settings
C 0.30–0.40 At Risk Reduce exploration
D 0.10–0.30 Collapse Warning Stability mode
F < 0.10 Collapse Imminent Load checkpoint

Links

Top comments (0)