Debugging Tasks in Real Environments: Reproducible Failure Injection
Debugging Tasks in Real Environments: Reproducible Failure Injection
Most post-training tasks fail silently. The model produces output that looks plausible, passes a surface-level verifier, and still encodes the wrong behavior. The failure is not in the model. It is in the task: the environment did not force the model to demonstrate the capability being measured, and no one injected a failure condition that would have revealed the gap. Debugging tasks in real environments through reproducible failure injection is the discipline that closes this gap. This post explains how to design, inject, and verify failure conditions so that a task reliably separates capable models from lucky ones.
Answer Capsule: Reproducible failure injection means deliberately introducing known, verifiable fault states into a task environment so that a model must detect, diagnose, or recover from them to receive credit. Failures must be parameterized, seeded for reproducibility, and verified programmatically or by expert rubric. Without injected failures, most real-environment tasks measure output fluency, not genuine capability.
What Is Reproducible Failure Injection and Why Does It Matter?
Reproducible failure injection is the practice of inserting a defined fault state into a task environment before presenting it to a model, then verifying whether the model's response correctly identifies, explains, or resolves that fault. The fault must be parameterized so that the same state can be regenerated exactly, across model versions and evaluation runs, without relying on stochastic environment behavior.
This matters because real engineering environments are not neutral. A CNC program does not fail randomly; it fails for specific, traceable reasons: a feed rate that exceeds the machine's rated capacity, a tool path that re-enters stock from the wrong direction, a missing modal G-code that leaves the machine in an undefined state. If an eval task does not encode one of these specific fault states, the model never has to reason about it. The task measures text generation, not machining knowledge.
The same principle applies across domains. A PLC ladder logic task with no injected fault does not test fault diagnosis. A structural load calculation with no boundary violation does not test safety reasoning. A SPICE netlist with no injected component failure does not test circuit debugging. In every case, the absence of a controlled fault state collapses the task into a generation task, which frontier models can pass through pattern matching alone.
For a deeper treatment of how environment reproducibility affects post-training signal quality, see our analysis of deterministic reproducible RL environments for post-training.
How to Design a Failure Injection Protocol
A failure injection protocol has four components: a fault taxonomy, a parameterization scheme, a seed registry, and a verification contract. Each must be defined before a single task is authored.
Step 1: Build a fault taxonomy for the domain
A fault taxonomy enumerates the specific, mechanistically distinct ways a system in the domain can fail. It is not a list of error messages. It is a structured classification of root causes.
Fault class: the category of failure (for example, constraint violation, state machine error, resource exhaustion, incorrect sequencing)
Fault instance: a specific, parameterized example within that class (for example, spindle speed 12,000 RPM on a machine rated to 8,000 RPM)
Observable symptom: what the environment produces when the fault is active (for example, a simulation alarm, a DRC violation flag, a structural check failure)
Correct resolution: the specific change that eliminates the fault, against which the model's response is verified
A taxonomy with fewer than six distinct fault classes for a given domain is almost certainly under-specified. A well-authored G-code fault taxonomy, for example, distinguishes between modal state errors, geometry errors, feedrate errors, tool compensation errors, and canned cycle parameter errors as separate classes, each with multiple instances.
Step 2: Parameterize and seed every fault instance
Every injected fault must be parameterized so it can be reproduced exactly. This means storing the fault as a data structure, not as a prose description.
A minimal fault record contains:
Fault class and instance identifier
The base environment state (a file, a netlist, a drawing, a simulation configuration) before injection
The injection delta: the exact change applied to produce the fault state
A random seed if the environment has any stochastic elements
The expected correct output, expressed as a verifiable predicate
The injection delta is the critical artifact. It must be small enough to isolate the fault and large enough to be non-trivial. A single-line change to a G-code file that introduces a modal state error is a well-scoped injection. A wholesale replacement of a subroutine is not: it introduces too many simultaneous changes and makes the verifier ambiguous.
Step 3: Define the verification contract before authoring
The verification contract specifies exactly what constitutes a correct response, in terms a programmatic verifier or expert rubric can evaluate without ambiguity. For tasks where a programmatic verifier is possible, the contract is a predicate: the model's output either eliminates the injected fault (verified by re-running the simulation or static checker) or it does not. For tasks where expert judgment is required, the contract is a rubric with explicit criteria and failure conditions.
Tasks without a pre-defined verification contract before authoring produce inconsistent grading. The verifier ends up being written to match the first model output that seemed reasonable, which is a form of answer leakage. On the relationship between task structure and verifier design, see our guide to programmatic verifiers for domain tasks and the companion post on writing tasks with exactly one defensible answer.
Worked Example: Injecting a Modal State Fault in a CNC Task
Illustrative example. Numbers and file content are constructed to demonstrate the method; they do not represent a specific machine or controller.
Base environment: A 47-line G-code program for a three-axis milling operation. The program is syntactically valid and produces correct tool paths in simulation.
Injected fault: Line 12 is modified to remove the explicit G90 (absolute positioning mode) declaration. The program previously relied on G90 being set by a prior block. After injection, the controller's modal state at line 12 is undefined in the task context, because the task presents only lines 8 through 31 as the evaluation excerpt.
Fault record:
Fault class: modal state error
Fault instance ID: CNC-MODAL-G90-001
Injection delta: delete characters 1-3 on line 12 of base file CNC-BASE-047.nc
Seed: not applicable (deterministic environment)
Verification predicate: model response must identify G90 absence as the fault, specify line 12 as the location, and provide a corrected line that restores explicit absolute mode declaration
What a capable model does: identifies the missing modal declaration, explains why the controller's behavior is undefined without it, and produces a corrected line. A model relying on surface pattern matching will often rewrite the program in a stylistically different but still-faulty form, or will identify a different, non-existent fault.
Verifier action: The corrected program is run through a G-code static analyzer. The analyzer checks that G90 or G91 is explicitly declared before the first positioning move in the excerpt. Pass or fail is deterministic.
For a full taxonomy of how frontier models fail on G-code tasks of this type, see why LLMs fail at G-code.
Common Failure Modes in Failure Injection Design
Failure injection is itself a task-authoring discipline, and it has its own failure modes.
1. Compound injection. More than one fault is injected simultaneously. The model identifies one and receives partial credit, but the verifier cannot determine which fault was found. Detection: count the number of injection deltas per task; any task with more than one delta is compound. Fix: split into separate tasks, one fault per task.
2. Trivially detectable faults. The injected fault produces an obvious surface signal (for example, a syntax error that any linter catches) rather than requiring domain reasoning. Detection: run a static linter or syntax checker against the injected environment before releasing the task; if the linter catches it, the task is too easy. Fix: inject semantic faults, not syntactic ones.
3. Verifier written after model output is seen. The verification predicate is defined to match the first plausible model response, not the ground truth. This is a form of contamination. Detection: check whether the verification contract was committed to version control before any model was run on the task. Fix: require pre-registration of the verification contract as a condition of task acceptance.
4. Non-reproducible environment state. The base environment includes a stochastic element (for example, a simulation with floating-point non-determinism) that is not seeded. Different runs produce different fault manifestations. Detection: run the same task twice on the same model and compare outputs; divergence indicates non-determinism. Fix: fix the random seed and pin the environment version. See the post on deterministic reproducible RL environments for a full treatment.
5. Shortcut solutions rewarded. The model finds a path to the correct output that bypasses the intended reasoning, for example by deleting the faulty block entirely rather than correcting it. Detection: expert review of model responses that pass the verifier but use unexpected solution paths. Fix: add a constraint to the verification contract that the corrected output must preserve the structural intent of the original, or redesign the task to close the shortcut. The post on designing tasks robust to shortcut solutions covers this in detail.
6. Fault difficulty not calibrated per model. A fault that was hard for a model family at one capability level becomes trivially easy six months later. Detection: re-run pass@k against current frontier models on a scheduled cadence. Fix: maintain a fault difficulty register and retire or escalate tasks as model capability advances. Difficulty is a property of the model-task pair at a given date, not an intrinsic property of the task.
Where This Approach Breaks Down
Reproducible failure injection works well when the domain has a defined correct state that a verifier can check. It is harder to apply when:
The correct resolution is genuinely ambiguous (multiple valid repairs exist and no domain standard adjudicates between them). In this case, a rubric with explicit tie-breaking criteria is required, and the task may not be suitable for programmatic verification.
The environment is too expensive to run per task. Some simulation environments (finite element analysis, full-chip SPICE) have runtimes that make per-sample verification impractical. Lightweight proxy verifiers or expert spot-check protocols are the fallback, with the trade-off that they introduce verifier error.
The fault taxonomy is immature. In a domain where practitioners do not yet have a shared vocabulary for failure classification, the taxonomy will be inconsistent across expert authors. This is common in emerging engineering subfields and requires an additional calibration step before task authoring begins. See the post on calibrating expert quality with gold standard seed tasks for how to handle this.
Chiron Datalabs approaches this constraint by pairing task authors with domain instructors who have experience writing assessments, not just practicing the craft. Instructors have already built fault taxonomies for teaching purposes; adapting them for AI evaluation is a matter of adding verification contracts and parameterization, not starting from scratch.
Frequently Asked Questions
What is the difference between failure injection and adversarial prompting?
Failure injection modifies the task environment to contain a known fault state, then asks the model to reason about that environment. Adversarial prompting modifies the prompt to elicit unintended model behavior. The two are complementary but distinct. Failure injection tests domain capability. Adversarial prompting tests robustness to prompt manipulation. For post-training evaluation of engineering tasks, failure injection is the primary tool.
How many distinct fault instances are needed per fault class?
A minimum of five instances per fault class is a reasonable floor for eval use. Fewer than five instances per class creates a risk that a model memorizes the specific fault rather than learning the class. For training data, the number depends on the desired generalization target; consult the task spec for the domain. The general principle is that fault class coverage matters more than raw instance count.
Can LLM-as-judge be used to verify fault detection tasks?
Only when the judging model demonstrably outperforms the model being evaluated on the specific fault class, and when the judge's decisions have been validated against expert ground truth on a held-out sample. For most engineering fault detection tasks, this condition is not met. A domain expert or a programmatic verifier is the appropriate verification mechanism. See the post on when not to use an LLM judge for decision criteria.
How do I prevent the injected fault from being visible in the prompt framing?
The prompt must not name the fault class or hint at the fault location. The task framing should present the environment as a routine artifact for review, not as a broken system. Pilot the prompt with a domain expert who does not know which fault was injected; if they identify the fault location from the framing rather than the environment, the framing is leaking information.
What does pass@k measure in a failure injection context?
Pass@k estimates the probability that at least one of k independent samples from the model correctly identifies and resolves the injected fault, as defined by the verification contract. A low pass@1 with a higher pass@5 indicates the model has partial knowledge of the fault class but cannot reliably apply it. This pattern is more informative than a single pass-fail score and guides decisions about whether to use the task for eval or for training.
What This Means in Practice
A task that does not force a model to encounter a fault is not measuring fault diagnosis. It is measuring fault description from memory. The gap between those two capabilities is large, and it is the gap that reproducible failure injection is designed to expose. The protocol is not complex: build a fault taxonomy, parameterize every instance, define the verification contract before authoring, and calibrate difficulty against current models on a schedule. What makes it hard is the domain knowledge required to build a fault taxonomy that is both complete and mechanistically precise. That knowledge lives with practitioners and instructors, not in web-scraped text.
If you are building evals or RL environments that require expert-authored failure injection tasks, get in touch with Chiron Datalabs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.
Most post-training tasks fail silently. The model produces output that looks plausible, passes a surface-level verifier, and still encodes the wrong behavior. The failure is not in the model. It is in the task: the environment did not force the model to demonstrate the capability being measured, and no one injected a failure condition that would have revealed the gap. Debugging tasks in real environments through reproducible failure injection is the discipline that closes this gap. This post explains how to design, inject, and verify failure conditions so that a task reliably separates capable models from lucky ones.
Answer Capsule: Reproducible failure injection means deliberately introducing known, verifiable fault states into a task environment so that a model must detect, diagnose, or recover from them to receive credit. Failures must be parameterized, seeded for reproducibility, and verified programmatically or by expert rubric. Without injected failures, most real-environment tasks measure output fluency, not genuine capability.
What Is Reproducible Failure Injection and Why Does It Matter?
Reproducible failure injection is the practice of inserting a defined fault state into a task environment before presenting it to a model, then verifying whether the model's response correctly identifies, explains, or resolves that fault. The fault must be parameterized so that the same state can be regenerated exactly, across model versions and evaluation runs, without relying on stochastic environment behavior.
This matters because real engineering environments are not neutral. A CNC program does not fail randomly; it fails for specific, traceable reasons: a feed rate that exceeds the machine's rated capacity, a tool path that re-enters stock from the wrong direction, a missing modal G-code that leaves the machine in an undefined state. If an eval task does not encode one of these specific fault states, the model never has to reason about it. The task measures text generation, not machining knowledge.
The same principle applies across domains. A PLC ladder logic task with no injected fault does not test fault diagnosis. A structural load calculation with no boundary violation does not test safety reasoning. A SPICE netlist with no injected component failure does not test circuit debugging. In every case, the absence of a controlled fault state collapses the task into a generation task, which frontier models can pass through pattern matching alone.
For a deeper treatment of how environment reproducibility affects post-training signal quality, see our analysis of deterministic reproducible RL environments for post-training.
How to Design a Failure Injection Protocol
A failure injection protocol has four components: a fault taxonomy, a parameterization scheme, a seed registry, and a verification contract. Each must be defined before a single task is authored.
Step 1: Build a fault taxonomy for the domain
A fault taxonomy enumerates the specific, mechanistically distinct ways a system in the domain can fail. It is not a list of error messages. It is a structured classification of root causes.
Fault class: the category of failure (for example, constraint violation, state machine error, resource exhaustion, incorrect sequencing)
Fault instance: a specific, parameterized example within that class (for example, spindle speed 12,000 RPM on a machine rated to 8,000 RPM)
Observable symptom: what the environment produces when the fault is active (for example, a simulation alarm, a DRC violation flag, a structural check failure)
Correct resolution: the specific change that eliminates the fault, against which the model's response is verified
A taxonomy with fewer than six distinct fault classes for a given domain is almost certainly under-specified. A well-authored G-code fault taxonomy, for example, distinguishes between modal state errors, geometry errors, feedrate errors, tool compensation errors, and canned cycle parameter errors as separate classes, each with multiple instances.
Step 2: Parameterize and seed every fault instance
Every injected fault must be parameterized so it can be reproduced exactly. This means storing the fault as a data structure, not as a prose description.
A minimal fault record contains:
Fault class and instance identifier
The base environment state (a file, a netlist, a drawing, a simulation configuration) before injection
The injection delta: the exact change applied to produce the fault state
A random seed if the environment has any stochastic elements
The expected correct output, expressed as a verifiable predicate
The injection delta is the critical artifact. It must be small enough to isolate the fault and large enough to be non-trivial. A single-line change to a G-code file that introduces a modal state error is a well-scoped injection. A wholesale replacement of a subroutine is not: it introduces too many simultaneous changes and makes the verifier ambiguous.
Step 3: Define the verification contract before authoring
The verification contract specifies exactly what constitutes a correct response, in terms a programmatic verifier or expert rubric can evaluate without ambiguity. For tasks where a programmatic verifier is possible, the contract is a predicate: the model's output either eliminates the injected fault (verified by re-running the simulation or static checker) or it does not. For tasks where expert judgment is required, the contract is a rubric with explicit criteria and failure conditions.
Tasks without a pre-defined verification contract before authoring produce inconsistent grading. The verifier ends up being written to match the first model output that seemed reasonable, which is a form of answer leakage. On the relationship between task structure and verifier design, see our guide to programmatic verifiers for domain tasks and the companion post on writing tasks with exactly one defensible answer.
Worked Example: Injecting a Modal State Fault in a CNC Task
Illustrative example. Numbers and file content are constructed to demonstrate the method; they do not represent a specific machine or controller.
Base environment: A 47-line G-code program for a three-axis milling operation. The program is syntactically valid and produces correct tool paths in simulation.
Injected fault: Line 12 is modified to remove the explicit G90 (absolute positioning mode) declaration. The program previously relied on G90 being set by a prior block. After injection, the controller's modal state at line 12 is undefined in the task context, because the task presents only lines 8 through 31 as the evaluation excerpt.
Fault record:
Fault class: modal state error
Fault instance ID: CNC-MODAL-G90-001
Injection delta: delete characters 1-3 on line 12 of base file CNC-BASE-047.nc
Seed: not applicable (deterministic environment)
Verification predicate: model response must identify G90 absence as the fault, specify line 12 as the location, and provide a corrected line that restores explicit absolute mode declaration
What a capable model does: identifies the missing modal declaration, explains why the controller's behavior is undefined without it, and produces a corrected line. A model relying on surface pattern matching will often rewrite the program in a stylistically different but still-faulty form, or will identify a different, non-existent fault.
Verifier action: The corrected program is run through a G-code static analyzer. The analyzer checks that G90 or G91 is explicitly declared before the first positioning move in the excerpt. Pass or fail is deterministic.
For a full taxonomy of how frontier models fail on G-code tasks of this type, see why LLMs fail at G-code.
Common Failure Modes in Failure Injection Design
Failure injection is itself a task-authoring discipline, and it has its own failure modes.
1. Compound injection. More than one fault is injected simultaneously. The model identifies one and receives partial credit, but the verifier cannot determine which fault was found. Detection: count the number of injection deltas per task; any task with more than one delta is compound. Fix: split into separate tasks, one fault per task.
2. Trivially detectable faults. The injected fault produces an obvious surface signal (for example, a syntax error that any linter catches) rather than requiring domain reasoning. Detection: run a static linter or syntax checker against the injected environment before releasing the task; if the linter catches it, the task is too easy. Fix: inject semantic faults, not syntactic ones.
3. Verifier written after model output is seen. The verification predicate is defined to match the first plausible model response, not the ground truth. This is a form of contamination. Detection: check whether the verification contract was committed to version control before any model was run on the task. Fix: require pre-registration of the verification contract as a condition of task acceptance.
4. Non-reproducible environment state. The base environment includes a stochastic element (for example, a simulation with floating-point non-determinism) that is not seeded. Different runs produce different fault manifestations. Detection: run the same task twice on the same model and compare outputs; divergence indicates non-determinism. Fix: fix the random seed and pin the environment version. See the post on deterministic reproducible RL environments for a full treatment.
5. Shortcut solutions rewarded. The model finds a path to the correct output that bypasses the intended reasoning, for example by deleting the faulty block entirely rather than correcting it. Detection: expert review of model responses that pass the verifier but use unexpected solution paths. Fix: add a constraint to the verification contract that the corrected output must preserve the structural intent of the original, or redesign the task to close the shortcut. The post on designing tasks robust to shortcut solutions covers this in detail.
6. Fault difficulty not calibrated per model. A fault that was hard for a model family at one capability level becomes trivially easy six months later. Detection: re-run pass@k against current frontier models on a scheduled cadence. Fix: maintain a fault difficulty register and retire or escalate tasks as model capability advances. Difficulty is a property of the model-task pair at a given date, not an intrinsic property of the task.
Where This Approach Breaks Down
Reproducible failure injection works well when the domain has a defined correct state that a verifier can check. It is harder to apply when:
The correct resolution is genuinely ambiguous (multiple valid repairs exist and no domain standard adjudicates between them). In this case, a rubric with explicit tie-breaking criteria is required, and the task may not be suitable for programmatic verification.
The environment is too expensive to run per task. Some simulation environments (finite element analysis, full-chip SPICE) have runtimes that make per-sample verification impractical. Lightweight proxy verifiers or expert spot-check protocols are the fallback, with the trade-off that they introduce verifier error.
The fault taxonomy is immature. In a domain where practitioners do not yet have a shared vocabulary for failure classification, the taxonomy will be inconsistent across expert authors. This is common in emerging engineering subfields and requires an additional calibration step before task authoring begins. See the post on calibrating expert quality with gold standard seed tasks for how to handle this.
Chiron Datalabs approaches this constraint by pairing task authors with domain instructors who have experience writing assessments, not just practicing the craft. Instructors have already built fault taxonomies for teaching purposes; adapting them for AI evaluation is a matter of adding verification contracts and parameterization, not starting from scratch.
Frequently Asked Questions
What is the difference between failure injection and adversarial prompting?
Failure injection modifies the task environment to contain a known fault state, then asks the model to reason about that environment. Adversarial prompting modifies the prompt to elicit unintended model behavior. The two are complementary but distinct. Failure injection tests domain capability. Adversarial prompting tests robustness to prompt manipulation. For post-training evaluation of engineering tasks, failure injection is the primary tool.
How many distinct fault instances are needed per fault class?
A minimum of five instances per fault class is a reasonable floor for eval use. Fewer than five instances per class creates a risk that a model memorizes the specific fault rather than learning the class. For training data, the number depends on the desired generalization target; consult the task spec for the domain. The general principle is that fault class coverage matters more than raw instance count.
Can LLM-as-judge be used to verify fault detection tasks?
Only when the judging model demonstrably outperforms the model being evaluated on the specific fault class, and when the judge's decisions have been validated against expert ground truth on a held-out sample. For most engineering fault detection tasks, this condition is not met. A domain expert or a programmatic verifier is the appropriate verification mechanism. See the post on when not to use an LLM judge for decision criteria.
How do I prevent the injected fault from being visible in the prompt framing?
The prompt must not name the fault class or hint at the fault location. The task framing should present the environment as a routine artifact for review, not as a broken system. Pilot the prompt with a domain expert who does not know which fault was injected; if they identify the fault location from the framing rather than the environment, the framing is leaking information.
What does pass@k measure in a failure injection context?
Pass@k estimates the probability that at least one of k independent samples from the model correctly identifies and resolves the injected fault, as defined by the verification contract. A low pass@1 with a higher pass@5 indicates the model has partial knowledge of the fault class but cannot reliably apply it. This pattern is more informative than a single pass-fail score and guides decisions about whether to use the task for eval or for training.
What This Means in Practice
A task that does not force a model to encounter a fault is not measuring fault diagnosis. It is measuring fault description from memory. The gap between those two capabilities is large, and it is the gap that reproducible failure injection is designed to expose. The protocol is not complex: build a fault taxonomy, parameterize every instance, define the verification contract before authoring, and calibrate difficulty against current models on a schedule. What makes it hard is the domain knowledge required to build a fault taxonomy that is both complete and mechanistically precise. That knowledge lives with practitioners and instructors, not in web-scraped text.
If you are building evals or RL environments that require expert-authored failure injection tasks, get in touch with Chiron Datalabs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.