Co-Stimulation Gating: When Should an LLM Stop to Check Its Own Reasoning?

When a language model solves a hard technical problem by writing a program, most of its intermediate steps are fine. A few are wrong, and those few ruin the answer. Checking every step is expensive. Checking steps the model itself finds suspicious raises too many false alarms, because models are unsure about many steps that turn out correct. Immunology faced a similar problem and offers a specific answer. In danger theory, an immune response fires only when two things coincide: a foreign-looking pattern, and independent evidence of tissue damage. This proposal tests whether that two-key rule makes a better policy for deciding when to spend extra compute re-checking a reasoning step. Here the "pattern" signal is the model's own suspicion about a step. The "damage" signal comes from actually executing the step's code: exceptions, NaN or infinite values, broken invariants, or values that jump by orders of magnitude.

The opportunity matters because expert domains are where this decision is hardest. Labeled data for training a verifier is scarce in theorem-driven science, competitive programming, and operations. Static domain knowledge does not fix errors that only show up when a rule is applied. The concrete bet is that a fixed, uncalibrated "fire only if both signals agree" rule transfers across domains better than a verifier learned on one domain. If a simple learned combination of the same two signals transfers just as well, the immune metaphor adds nothing beyond feature engineering, and we will report that.

Core Claim

Program-of-Thought prompting has the model write code for each reasoning step and run it. Under this setting, we claim that requiring both a high "adaptive" suspicion score and a high runtime "danger" score yields more useful interventions at fixed compute than three alternatives: either signal alone, spending the same compute uniformly, or a fusion of the two signals learned on a different domain. The claim is specifically about the label-free, cross-domain regime. In-domain with plenty of labels, we expect a learned fuser to match or beat the fixed rule.

The rule is easy to state. Let $a_t$ be the adaptive suspicion at step $t$, measured as the disagreement among $k$ cheap resamples of that step's computed value. Let $d_t$ be accumulated danger: a running count of execution anomalies that decays with a half-life $h$, so a single stray warning fades but repeated ones build up.

$$d_t = 2^{-1/h}\, d_{t-1} + s_t, \qquad \text{intervene at } t \iff a_t > \theta_a \;\wedge\; d_t > \theta_d,$$

Here $s_t$ is the number of runtime anomalies raised by step $t$, and $\theta_a, \theta_d$ are thresholds set once on a single development domain and then frozen. An intervention means re-solving the flagged step in an isolated context, in the style of divide-and-conquer prompting.

What the Metaphor Does and Does Not Buy

The motivating evidence comes from second-generation artificial immune systems. Twycross, Aickelin and Whitbrook's tlr algorithm, in Detecting Anomalous Process Behaviour using Second Generation Artificial Immune Systems, fuses a system-call pattern stream with three host telemetry signals. On a wuftpd exploit benchmark it reached a G-mean of 0.80 with a false-positive rate of 0.15, against 0.60 and 0.60 for the policy-based systrace. Earlier, libtissue - implementing innate immunity showed qualitatively that adding context signals sharpens response profiles. The design principles come from "Going Back to our Roots": Second Generation Biocomputing. These works give us the hypothesis but no language models.

They also constrain us. Twycross et al. hand-pruned 14 candidate signals to 3 for one server. Signal choice is exactly the domain-dependent step that could make the method a pile of hand-tuning. We therefore commit in advance to one generic set of runtime danger signals that applies to any Python reasoning step, and we never tune it per domain.

The closest LLM work is Discovering Agentic Safety Specifications from 1-Bit Danger Signals. EPO-Safe lets an agent reflect over 5–15 episodes on an external binary danger oracle to write safety rules. It found that reward-only reflection accelerated reward hacking, and that the method tolerated 50% oracle false positives with about 15% safety degradation. We differ in three ways. Our danger signal is computed from execution rather than supplied by an oracle. It acts within a single problem to gate compute rather than across episodes to write rules. And we test the conjunction itself against single-signal and learned alternatives, which EPO-Safe does not.

Adaptive Coopetition supplies an important precedent: coarse verifier signals, a process reward plus semantic similarity, can steer multi-agent reasoning. It reached 54.0% on DeepMath-103K. Its signals are learned or model-based rather than grounded in execution, which is the variable we isolate.

Several papers motivate why the adaptive signal alone is unreliable. Beyond Code shows self-generated plans can hurt code generation, while external knowledge-enhanced steps lifted Starcoderbase-1B Pass@5 from 5.15% to 12.40%. Evaluating Large Language Models with Runtime Behavior of Program Execution shows GPT-4-Turbo at 75% task accuracy but only 42.5% incremental consistency, with execution-path prediction as the bottleneck. Evaluating Intermediate Reasoning of Code-Assisted LLMs for Mathematics finds correct final answers produced by unsound programs.

The method we reuse for interventions is divide-and-conquer prompting, which re-solves sub-tasks in isolated contexts to stop error accumulation. Finally, TheoremQA both motivates and constrains the work. Supplying theorem definitions did not significantly help, so the gap lies in applying knowledge, not retrieving it. That is why our danger signal watches execution rather than documents.

Research Program

We build a step-level PoT harness. The model emits one code cell per reasoning step; each cell runs in a sandbox with persistent state.

The danger channel records a fixed, generic set of anomalies:

  • uncaught exceptions;
  • NaN or infinite values;
  • a change in the shape or type of a variable that is used downstream;
  • a scalar whose magnitude changes by more than a fixed factor between steps;
  • failed assertions the model was prompted to write about its own variables, such as "probability lies in [0,1]" or "length is nonnegative";
  • on code tasks, failures on the provided sample test inputs.

The adaptive channel resamples each step's value $k$ times at low temperature and measures their disagreement.

Thresholds and half-life are set once on a development split of GSM8K-style problems and then frozen. We study three questions in order. First, does the conjunction raise intervention precision, meaning the fraction of interventions that land on solutions that were wrong at that point? Second, does higher precision translate into accuracy at matched compute? Third, does the frozen rule transfer to TheoremQA, DeepMath-103K and CodeStepsEval better than a fuser learned on the development domain?

Open models at two scales are the primary subjects, with Gemma-3 included because both AdCo and the incomplete-conditions work report numbers on it. A frontier API model is run on TheoremQA for comparison with the reported GPT-4 figure. The proprietary Microsoft incident data in Recommending Root-Cause and Mitigation Steps for Cloud Incidents is not available to us. That paper's stated gap, the absence of live telemetry, motivates a later extension, but we do not claim results there.

Baselines

Do nothing. The naive reference point is single-pass step-wise PoT with no intervention, run with the same model and harness. Every gain is measured against it. For context, the strongest reported TheoremQA figure in our file is GPT-4 with PoT at 51.0% accuracy (TheoremQA). We will rerun that configuration in our harness rather than compare across harnesses.

Uniform compute. Self-consistency majority voting and uniformly re-solving every step are run with the total token budget equal to the gated method's average spend. This tests whether gating beats simply spending more.

Danger-only gating. Intervening on any runtime anomaly is essentially execution-feedback self-debugging. It is the strongest simple competitor, because runtime errors are highly informative on code.

Adaptive-only gating. Intervening on high resample disagreement is the uncertainty-triggered baseline.

Disjunction and sum gates. OR and weighted-sum combinations of the same two scores isolate the conjunction from the mere presence of two signals.

Learned fuser. A logistic regression on $(a_t, d_t)$ and their history is trained on step-level correctness labels from the development domain, then applied frozen to the target domains. A second copy is trained in-domain, which gives the fuser its best case.

Coarse-verifier method. On DeepMath-103K the strongest reported method is AdCo at 54.0% accuracy (Adaptive Coopetition). Because AdCo uses multiple agents and different models, we report that number for orientation. We also run a matched-budget variant that uses a process-reward score in place of our danger signal inside the same gate. This isolates execution grounding against model-based verification.

CodeStepsEval reference. Here the reference point is the Starcoderbase-1B knowledge-enhanced Pass@5 of 12.40% (Beyond Code). That configuration uses externally refined plans, so it is an upper-reference rather than a like-for-like competitor.

Ablation. Removing the half-life accumulation (setting $d_t = s_t$) tests whether the "tissue" ingredient of decaying, accumulating evidence matters at all.

All methods share the model, the sandbox, the prompts, and the per-problem token budget. Each gets an equal threshold-search budget on the same development split.

What counts as winning. We beat the baselines if, at matched tokens, the conjunction gate improves final accuracy over danger-only gating and over the cross-domain learned fuser on at least two of the three target benchmarks, with paired bootstrap intervals excluding zero.

Why not just…?

Why not just run the code and fix whatever errors? This is the most serious threat. On code-heavy benchmarks, danger-only gating may capture nearly all the benefit. The relevant evidence points the other way on part of the problem: Al-Khalili et al. show unsound programs that run cleanly and give right answers, and many anomalies such as magnitude jumps are benign in legitimate computations. These are exactly the false alarms that systrace-style rules generate, as in its 0.60 false-positive rate in Twycross et al.. The danger-only baseline settles this question directly. If it matches the conjunction, the paper reports that execution feedback alone suffices.

Why not just train a verifier on both signals? In-domain, a learned fuser should win, and we expect it to. Our claim is narrower: in expert domains, labels are scarce, and a learned fuser overfits to the anomaly statistics of its training domain. The cross-domain fuser baseline is the decisive comparison. A tie there means the biological rule is just one reasonable hand-picked feature combination, and we would say so.

Why not just use a process reward model or multi-agent debate? AdCo shows coarse model-based verifiers help. The same paper reports that unguided collaboration collapses. EPO-Safe shows that reflection without an independent channel promotes reward hacking. A model-based verifier shares failure modes with the model it checks, whereas runtime signals do not. The process-reward-in-the-gate variant measures whether that independence matters at matched compute.

Why not just give the model the relevant theorems or documentation? TheoremQA already reports that theorem augmentation did not significantly help. We include the augmented prompt only as a sanity baseline on TheoremQA.

Decisive Checks

The first check is intervention precision. On every benchmark, step-level labels come from comparing each step's value against a reference solution's trace. We plot precision against recall for each gate. The immune hypothesis predicts the conjunction dominates both single-signal gates at low intervention rates, mirroring the drop in false positives from 0.60 to 0.15 in the tlr work.

The second check is accuracy against tokens spent on TheoremQA, DeepMath-103K and CodeStepsEval, reported with paired bootstrap intervals.

The third check is the transfer test. Every gate is frozen after tuning on the development domain. The learned fuser is trained on the same domain, and we report the gap between it and its in-domain copy alongside the fixed rule's change across domains.

The fourth check is a stress test. Synthetic benign anomalies are injected into correct steps, for example harmless magnitude jumps. This measures how false alarms grow for each gate, in the spirit of EPO-Safe's noise-tolerance test.

The project's outcome hinges on whether the conjunction beats both danger-only gating and the cross-domain fuser at matched compute. If it does not, the result is still useful. It would show that, for LLM reasoning, the danger-theory metaphor reduces to "run the code," and that whatever extra it adds must come from learning rather than from biology.