1. StateBench-Style State Tracking as a Critic Signal Source

Before you can build a critic agent that flags hallucinations, you need a replay harness that exposes whether your LLM is actually tracking state across decision steps or just reading the most recent input — these are fundamentally different failure modes with different mitigations.

  • State tracking vs. recency bias are distinguishable failure modes only when you test against full promotion histories, not isolated prompts — a model that always reads the last line looks correct on shallow tests.
  • An UNKNOWN option in your prompt forces the model to surface uncertainty rather than confabulate a confident wrong answer, which is exactly the signal a downstream critic needs to trigger a review branch.
  • Replay harnesses over synthetic logs let you stress-test state tracking against realistic edge cases — out-of-order events, rollbacks, partial failures — before those sequences appear in production.
TECHNICAL DEEP DIVE & CODE ARTIFACTS Expand [+]

The core insight from StateBench-style evaluation is that LLMs don't hallucinate uniformly — they hallucinate predictably at state boundaries, specifically when asked to reason about sequences where earlier context contradicts a recent signal. Building a critic layer on top of this means instrumenting your pipeline to capture the full decision context at each step, not just the LLM's output, so the critic can compare the model's stated rationale against the actual state trace. If the model claims service X is at version 3.1 but the deployment log shows a rollback to 3.0 two steps prior, that's a detectable contradiction — not a subtle hallucination, just one that requires state-aware comparison logic to catch. Source: [How to Test LLM State Tracking With a StateBench-Style Deployment Log] — (https://towardsdatascience.com/how-to-test-llm-state-tracking-with-a-statebench-style-deployment-log/)

For a platform team, the practical architecture here is a structured log per pipeline run that records the state vector at each node transition — essentially a typed snapshot of everything the LLM should have known when it made its decision. The critic agent gets both the snapshot and the LLM output and runs a consistency check: does the conclusion follow from the known state, and did the model express appropriate uncertainty where state was ambiguous? This is cheaper than a second full LLM call for every decision — you can encode most consistency rules as deterministic checks and only escalate to an LLM critic for cases where the contradiction requires semantic reasoning.

Reference Architecture
// TypeScript: Critic consistency check with tolerance threshold
import { z } from 'zod';

const StateSnapshot = z.object({
  stepId: z.string(),
  knownVersions: z.record(z.string(), z.string()),
  recentEvents: z.array(z.object({ service: z.string(), event: z.string(), ts: z.number() })),
});

const LLMDecision = z.object({
  conclusion: z.string(),
  referencedVersions: z.record(z.string(), z.string()),
  confidenceScore: z.number().min(0).max(1),
  expressedUncertainty: z.boolean(),
});

type CriticResult =
  | { verdict: 'approved' }
  | { verdict: 'flagged'; contradictions: string[]; requiresHuman: boolean };

function runConsistencyCheck(
  snapshot: z.infer<typeof StateSnapshot>,
  decision: z.infer<typeof LLMDecision>,
  toleranceThreshold: number = 0.85
): CriticResult {
  const contradictions: string[] = [];

  for (const [svc, claimedVersion] of Object.entries(decision.referencedVersions)) {
    const knownVersion = snapshot.knownVersions[svc];
    if (knownVersion && knownVersion !== claimedVersion) {
      contradictions.push(
        `Service '${svc}': LLM claimed ${claimedVersion}, state log shows ${knownVersion}`
      );
    }
  }

  if (contradictions.length === 0) return { verdict: 'approved' };

  // Escalate to human if confidence is high despite contradictions — most dangerous case
  const requiresHuman = decision.confidenceScore > toleranceThreshold && !decision.expressedUncertainty;

  return { verdict: 'flagged', contradictions, requiresHuman };
}
State Interaction Chart
sequenceDiagram participant Orchestrator participant DecisionLLM participant StateLog participant CriticAgent participant EscalationQueue Orchestrator->>StateLog: Snapshot state vector Orchestrator->>DecisionLLM: Prompt with state context DecisionLLM-->>Orchestrator: Decision + rationale Orchestrator->>StateLog: Append decision + rationale Orchestrator->>CriticAgent: State snapshot + decision CriticAgent->>CriticAgent: Consistency check alt Contradiction detected CriticAgent->>EscalationQueue: Flag with diff else Within tolerance CriticAgent-->>Orchestrator: Approved end

2. Structured Context Indexing as a Hallucination Prevention Primitive

A critic agent can catch hallucinations after the fact, but a well-structured context layer — typed indexes, project-scoped onboarding documents, and a persistent memory store — reduces the rate of hallucinations the critic has to handle in the first place.

  • Annotated INDEX.md files function like a schema registry for the LLM's retrieval layer — they tell the model what exists, where it lives, and what's authoritative, cutting the surface area for confabulated facts.
  • CLAUDE.md-style onboarding docs are a governance artifact as much as a usability one — they set the decision boundaries and verification expectations the agent should apply before committing to an output.
  • Encoding preferences as config, not prose, lets your critic agent compare LLM behavior against a machine-readable spec rather than trying to interpret intent from a system prompt.
TECHNICAL DEEP DIVE & CODE ARTIFACTS Expand [+]

The hallucination mitigation problem has two distinct phases: prevention upstream and detection downstream. What the structured context approach addresses is the prevention side — when an LLM has access to a well-organized, indexed knowledge layer with explicit scope boundaries, it's less likely to fill gaps with invented facts because the retrieval path is clear. An annotated index that tells the model 'authoritative deployment config lives here, not in the codebase comments' removes a whole class of confabulation that happens when the model has to infer structure. Source: [How to Work and Compound with AI] — (https://eugeneyan.com/writing/working-with-ai)

AIFor platform teams, this maps cleanly to a context governance layer: a structured, versioned document per agent role that specifies what knowledge sources are in-scope, what verification steps are mandatory before the agent outputs a decision, and what constitutes an ambiguous state requiring escalation. When your critic agent runs, it can check not just whether the LLM's conclusion is consistent with the state log, but whether the LLM stayed within its defined knowledge scope — referencing only indexed sources rather than interpolating from training data. That second check is harder but catches a different class of hallucination: not factual contradiction but scope drift, where the model reasons confidently from knowledge it shouldn't be using at all.

Reference Architecture
// TypeScript: Context scope validator for critic agent
interface KnowledgeIndex {
  entries: Array<{
    id: string;
    path: string;
    authoritative: boolean;
    scope: 'deployment' | 'config' | 'codebase' | 'external';
  }>;
}

interface LLMOutput {
  conclusion: string;
  citedSources: string[]; // paths or IDs the LLM claims to have used
}

function checkScopeCompliance(
  output: LLMOutput,
  index: KnowledgeIndex,
  allowedScopes: Array<KnowledgeIndex['entries'][number]['scope']>
): { compliant: boolean; violations: string[] } {
  const indexedPaths = new Set(index.entries.map(e => e.path));
  const scopeMap = new Map(index.entries.map(e => [e.path, e.scope]));

  const violations: string[] = [];

  for (const source of output.citedSources) {
    if (!indexedPaths.has(source)) {
      violations.push(`Unindexed source: '${source}' — potential training data interpolation`);
      continue;
    }
    const scope = scopeMap.get(source)!;
    if (!allowedScopes.includes(scope)) {
      violations.push(`Out-of-scope source: '${source}' has scope '${scope}', not allowed here`);
    }
  }

  return { compliant: violations.length === 0, violations };
}
State Interaction Chart
flowchart TD A[Agent Context Layer] --> B[INDEX.md - Scoped Knowledge Index] A --> C[CLAUDE.md - Decision Boundaries] A --> D[Memory Store - Persisted Insights] B --> E[LLM Decision Node] C --> E D --> E E --> F[Output + Source Citations] F --> G{Critic: Scope Check} G -->|Source in index| H[Consistency Check] G -->|Source out of scope| I[Flag: Scope Drift] H -->|Within tolerance| J[Approved] H -->|Contradiction found| K[Flag: State Contradiction]

3. Engineering Judgment Preservation as a Critic Agent Design Constraint

The critic agent pattern only works if the engineer reviewing its escalations is capable of making the judgment call — which means the system design must actively preserve the human reviewer's ability to evaluate LLM outputs, not just route them to a queue.

  • Skill decay under automation is a structural risk in agentic pipelines: if engineers only see escalated edge cases and never trace through normal decisions, they lose the fluency needed to catch subtle hallucinations the critic misses.
  • Verification as a practiced skill means your human-in-the-loop design should include periodic full-trace reviews of approved decisions, not just rejected ones — passive oversight degrades faster than active engagement.
  • Critic escalation diffs, not just flags, give reviewers the specific contradiction to evaluate rather than asking them to re-derive the full context — this preserves judgment without requiring every reviewer to hold the entire pipeline state in their head.
TECHNICAL DEEP DIVE & CODE ARTIFACTS Expand [+]

The concern about agentic skill decay isn't abstract — it has a direct impact on how you design your critic agent's escalation interface. If you route flagged decisions to a human reviewer who hasn't been in the loop on the normal flow, you're essentially asking them to cold-evaluate a complex state transition with no prior context. That's the worst possible condition for good judgment: high stakes, cold start, time pressure. The mitigation is to treat reviewer engagement as a first-class design concern — building escalation interfaces that surface the full decision trace, not just the flag, and structuring on-call rotations so reviewers stay familiar with the pipeline's normal behavior. Source: [Agentic Skill Decay] — (https://addyosmani.com/blog/agentic-skill-decay/)

AIThere's a compounding effect here worth naming explicitly: as critic agents get better at catching obvious hallucinations, the cases that reach human reviewers become progressively harder and more subtle. This is the inverse of the usual automation story — instead of automation making human work easier over time, it makes the remaining human decisions more demanding. Your governance model needs to account for this by investing in reviewer calibration, not just critic accuracy. Periodic 'shadow mode' runs where senior engineers evaluate a sample of approved decisions alongside the critic's verdicts — essentially auditing the critic itself — close this loop and keep human judgment sharp enough to catch the cases that fall outside the critic's detection threshold.

Reference Architecture
// TypeScript: Escalation payload with full decision trace for human reviewer
interface EscalationPayload {
  pipelineRunId: string;
  stepId: string;
  stateSnapshot: Record<string, unknown>;
  llmPrompt: string;
  llmOutput: string;
  criticVerdicts: Array<{
    checkType: 'state_consistency' | 'scope_compliance' | 'confidence_mismatch';
    passed: boolean;
    detail: string;
  }>;
  contradictions: string[];
  requiresHuman: boolean;
  suggestedReviewFocus: string; // critic's plain-language summary for the reviewer
}

function buildEscalationPayload(
  runId: string,
  stepId: string,
  snapshot: Record<string, unknown>,
  prompt: string,
  output: string,
  verdicts: EscalationPayload['criticVerdicts'],
  contradictions: string[]
): EscalationPayload {
  const confidenceMismatch = verdicts.find(v => v.checkType === 'confidence_mismatch' && !v.passed);
  const scopeDrift = verdicts.find(v => v.checkType === 'scope_compliance' && !v.passed);

  const focus = confidenceMismatch
    ? 'Model expressed high confidence despite state contradictions — verify decision basis'
    : scopeDrift
    ? 'Model cited out-of-scope sources — check if conclusion relies on training data interpolation'
    : 'Review contradictions between claimed state and deployment log';

  return {
    pipelineRunId: runId,
    stepId,
    stateSnapshot: snapshot,
    llmPrompt: prompt,
    llmOutput: output,
    criticVerdicts: verdicts,
    contradictions,
    requiresHuman: verdicts.some(v => !v.passed),
    suggestedReviewFocus: focus,
  };
}
State Interaction Chart
flowchart TD A[Pipeline Decision] --> B[Critic Agent] B -->|Approved| C[Decision Log] B -->|Flagged| D[Escalation Queue] D --> E[Human Reviewer - Full Trace] E -->|Override Approve| C E -->|Confirm Reject| F[Incident + Retraining Signal] C --> G{Periodic Audit Sample} G --> H[Senior Engineer Shadow Review] H --> I[Critic Calibration Feedback] I --> B