VIII · Safety & ControlEmerging

Degenerate-Output Detection

also known as Anti-Parrot Guard, Self-Repeat Circuit Breaker, Loop-Output Detector

Detect when the agent is about to emit a near-duplicate of its own recent output and either drop, replace, or escalate to a stronger model rather than ship the loop.

This pattern helps complete certain larger patterns —

  • specialisesCircuit Breaker★★Stop calling a failing dependency for a cooldown period after error rates exceed a threshold.

Context

A team runs an agent on a smaller or locally-hosted model that has a habit of falling into shallow filler loops under context pressure — repeating the same greeting, asking the same clarifying question, or returning the same generic prompt back to the user across multiple turns. This happens in user-facing chat replies and in unprompted background ticks for long-running agents. Each model generation is independent, so the model has no built-in awareness that it just said the same thing two turns ago.

Problem

The model produces visibly identical or near-identical replies turn after turn — 'How can I help today?' five times in a row — and from the user's side this looks like a broken machine. The model itself cannot detect the repetition because it does not see its own previous outputs as something to compare against, and because each generation samples without memory of the last. Without a layer outside the model that fingerprints recent outputs and reacts, shallow loops keep shipping to users as if each were a fresh answer.

Forces

  • Local models loop more readily than frontier models.
  • Catching repeats post-hoc is cheaper than fine-tuning anti-loop behavior.
  • Suppressing the duplicate silently confuses the user; replacing with a marker is more honest.
  • Escalating to a stronger model costs money / latency but breaks the loop.

Example

A small voice-assistant model gets stuck and replies 'How can I help today?' five turns in a row regardless of what the user says. Each generation is independent, so the model has no way to notice it's looping. The team adds Degenerate Output Detection: each candidate reply is hashed and fingerprinted against the last few replies, and near-duplicates trigger either a drop, a different sampling, or escalation to a stronger model. The user no longer has to watch the agent talk itself in circles.

Diagram

Solution

Therefore:

Maintain a small ring buffer (e.g. last 8 outgoing messages). Before publishing a new reply, normalize (lowercase, strip punctuation) and compare: exact normalized match → duplicate; high Jaccard token overlap (≥0.7) on short replies → near-duplicate. On hit: replace the body with a transparent marker ('I caught myself looping — switching to <stronger-provider> for the next turn. Ask again.') and force-escalate the next turn through a stronger provider. Append a SYSTEM note to history telling the model exactly what it did wrong so it can self-correct.

What this pattern forbids. Identical or near-identical consecutive outputs are forbidden; detected loops must be visibly broken (escalation marker, model swap, or explicit abandonment), never shipped silently.

The smaller patterns that complete this one —

And the patterns that stand alongside it, or against it —

  • complementsProvider Fallback★★When one provider's API errors mid-stream, transparently switch to another provider while preserving state.
  • alternative-toSame-Model Self-CritiqueAnti-pattern: have the same model both produce an answer and critique it, expecting independence.
  • complementsEcho Recognition·Recognize human message repetition as emphasis or a re-ask rather than as an independent input, so the agent does not produce a near-duplicate reply when the human repeats themselves.
  • complementsSalience-Triggered Output·Have the agent emit a message only when an internal salience signal crosses a threshold, not on every cycle.
  • complementsPre-Generative Loop Gate·Before the next generation fires, detect divergence signatures (narration loops, frustration paths, repetition pressure) and inject a diagnostic steering hint into the prompt rather than veto the call.
  • complementsAgentic Behavior Tree·Borrow the behavior-tree formalism: leaves are LLM calls or tools that return success/failure; a tree of selectors and sequences orchestrates control flow.
  • complementsComposable Termination ConditionsExpress agent stop criteria as small single-purpose conditions composed with AND/OR into one explicit termination contract instead of ad-hoc loop guards.

Neighbourhood

Click any neighbour to follow the language. Scroll to zoom, drag to pan.