Skip to main content

What Diagnostic Reasoning Does

After an experiment runs and the jury produces verdicts, the diagnostic system answers: why did items fail, and what should change? It works in three stages:
  1. Gap classification — map each failing verdict to a category (agent error, plan gap, missing knowledge, etc.)
  2. Deterministic reasoning — apply rule-based logic to produce actionable fixes
  3. LLM fallback — for checks the rules can’t resolve, an LLM analyzes execution traces and proposes new artifacts

Gap Categories

Every failing verdict check is classified into a gap category that identifies where in the system the problem lives:

DiagnosticAnalyzer

Entry point for analysis. Takes an ExperimentResult and produces a DiagnosticReport:

GapClassifier

Assigns gap categories to verdict checks. The default HeuristicGapClassifier uses 22 judge-specific classification rules to map failures to categories based on the judge name, check content, and available analysis data.

DiagnosticReport

GapDistribution.dominant() returns the most frequent gap category — the highest-leverage fix target.

DiagnosticReasoner

Transforms a DiagnosticReport into actionable remediation:

ReasoningContext

Provides the full data menu for reasoning — analysis output, execution plan, trajectory exhaust, and file pointers: Helper methods: unusedTools(), errorToolResults(), toolUsesByName(String).

DeterministicReasoner

Rule-based reasoning with two rule categories: Verdict rules (fire on failing judge checks):
  • Pattern-match on gap category and structured analysis data
  • Target specific components: planner-prompt, pom-upgrader, agent-prompt, dependency-analysis
Trajectory rules (fire on execution context regardless of judge outcomes):
  • Detect efficiency gaps where the agent recovered but deterministic tools could have prevented the problem
  • Examples: unused tools, implicit JDK dependencies, repeated build errors, format violations

LlmDiagnosticReasoner

Handles checks that deterministic rules can’t resolve. Analyzes execution traces (thinking, tool calls, results) and produces:
  • RemediationActions — fixes with LLM_INFERRED confidence
  • RemediationProposals — new deterministic artifacts (rules, KB entries, tool specs) for the flywheel

CompositeDiagnosticReasoner

Chains deterministic and LLM reasoning:
  1. Deterministic layer runs first (fast, proof-based)
  2. If unresolved checks remain and an LLM fallback is available, forward them to the LLM
  3. Merge results into a single RemediationReport
If deterministic reasoning resolves all checks, the LLM is never called.

RemediationReport

RemediationAction

Each action targets a specific component and carries a confidence level:

RemediationProposal

LLM-discovered patterns that can become new deterministic infrastructure:

The Flywheel

RemediationProposals are the flywheel mechanism. When the LLM discovers a novel failure pattern:
  1. It creates a RemediationProposal (e.g., a new deterministic reasoner rule)
  2. A human reviews and applies the proposal
  3. The new rule is added to DeterministicReasoner
  4. On the next run, that pattern is resolved deterministically — faster, cheaper, and with higher confidence
Over time, the LLM fallback is invoked less as more patterns move into deterministic rules.

Cross-Run Aggregation

DiagnosticAggregator analyzes multiple DiagnosticReport instances from repeated runs to detect stochasticity:
An item classified as AGENT_EXECUTION_GAP in one run and PLAN_GENERATION_GAP in another is flagged as stochastic. Stochastic items need N≥3 runs before you can draw reliable conclusions. Stable items are immediately actionable.

Efficiency Evaluation

EfficiencyEvaluator scores execution efficiency across four metrics:
Metrics gracefully degrade — if data for a metric is missing, the metric is omitted rather than failing.

Behavioral Diagnostics (Markov Analysis)

Gap classification and remediation operate on judge verdicts — the outcome layer. A complementary diagnostic lens operates on tool-call sequences — the behavioral layer. The agent-experiment-template includes Markov chain analysis scripts that reveal how the agent behaves, not just what it produces.

Loop amplification

The Markov analysis computes loop amplification — how many times the agent revisits a state before moving forward. High amplification indicates friction or failure loops:

Loop types

Not all loops are problems. Classify before intervening:

Interpretation output

The template’s make_markov_analysis.py writes analysis/markov-interpretation.md with:
  • Per-variant loop amplification summary with threshold-based classification
  • Recommended intervention lever for each high-amplification state
  • Suggested next variant with a hypothesis template
This connects the behavioral DIAGNOSE step to the flywheel’s INTERVENE step — the interpretation tells you which lever to pull based on measured state-transition patterns. See the Improvement Flywheel for the full methodology.

Pipeline

Analyze, plan, and execute — the three pipeline phases

Jury System

Three-tier evaluation: deterministic, structural, semantic