Agentic Pattern Libraryby Vikas Goyal
← All patterns
64

Chaos Hardening Loop

Also known as: agentic load-and-fix loop, AI chaos engineering, pre-launch hardening loop

A supervised, long-running agent drives heavy load and deliberate failures against a staging copy of the system, reads the telemetry, fixes what breaks and reruns, against invariants written down in advance.

TrackAI-native software delivery FamilyVerify Maturity Emerging ChangesVerificationCoordination
01

Problem

A service that works for a few thousand internal users says little about launch day. Load tests are usually run a few times by hand, read by busy engineers, and followed by fixes weeks later. Rare failures, such as thousands of clients reconnecting at once or a database stalling mid-spike, are rehearsed once if at all. Teams launch hoping the system holds, and learn its limits in production.

  • Real scale and real failures are hard to reproduce on demand.
  • Each load run produces more telemetry than people can read closely.
  • Many fixes are plausible but wrong, and only the next run shows it.
  • Some changes (schema, storage layout) are hard to undo and shape the future.
02

Solution

Run a supervised agent loop against a staging environment that mirrors production. Before starting, write down the invariants that must hold, such as “documents open almost instantly” and “an acknowledged edit always persists”. A harness drives one scenario at a time to saturation, well beyond expected traffic (around 10× is a common target), and injects failures: killed servers, a stalled database, a deploy in the middle of a spike. The agent reads the telemetry, proposes a few options with a recommendation, and for easy-to-undo changes writes the fix, has a separate reviewer agent check it, ships it to staging behind a runtime flag and reruns. Hard-to-undo changes go to a person to decide. A coordinator can spread scenarios across sub-agents, though a single agent is often cheaper. Track the loop’s own spend, and stop exploration that isn’t paying off.

03

Diagram

invariants · fixed for every round Harness~10× load+ kill · stall Stagingmirrors prod Agentreads telemetryoptions + pick Easy to undofix → reviewer → flag Hard to undoperson decides deploy to staging · rerun the scenario after approval

Every round adds load or failure, reads the signals, and ships a reviewed fix to staging. Invariants stay fixed; hard-to-undo changes wait for a person.

04

When to use

Use it when

  • A launch or traffic step-change is coming
  • A staging environment can mirror production at scale
  • Telemetry is available to the agent (for example through an observability connector)
  • The team can write down the invariants that must hold

Avoid it when

  • No realistic staging environment; production-only systems
  • Telemetry too coarse to attribute problems (see Agent-Legible Systems)
  • Budgets that can't absorb continuous agent runs for days or weeks
05

Trade-offs

Latency Days to weeks of continuous rounds before launch
Cost Continuous inference plus staging at scale
Complexity Harness, fault injection, reviewer, flags, approvals
Reliability Failure modes rehearsed before users meet them

Gains

  • Launch-scale behavior known before launch
  • Many more fix cycles than a team could run by hand
  • Fixes arrive behind flags, so production mitigation needs no deploy

Costs

  • Inference spend can run high, especially while the loop is being set up
  • Needs a production-like staging environment
  • Wrong but plausible fixes waste rounds without good attribution
06

Worked example

Scenario
The Linkwatch team expects launch traffic around 20× today's level. It runs a hardening loop on staging for two weeks.
  1. InvariantsThe team writes 3: link pages load in under 300 ms at the 95th percentile; a saved link is never lost; a node restart recovers within 30 seconds.
  2. ScenarioThe harness pushes link creation to 10× expected peak and kills a server mid-run. Save latency triples and a few saves are lost.
  3. AgentReads the per-query telemetry: one insert scans the whole table to check for duplicates. It proposes an index (easy to undo) or a schema change (hard to undo) and recommends the index.
  4. Review + shipA reviewer agent checks the index change. It ships to staging behind a flag. The rerun holds all 3 invariants.
  5. Person decidesA later round suggests changing how link history is stored. That’s hard to undo, so the agent presents 3 options and the tech lead picks one.
07

Failure modes

FailureSymptomMitigation
Goal driftAfter many rounds, the agent optimizes something nobody asked forKeep invariants and outcome fixed and restate them every round
Plausible wrong fixChange looks right but the next run shows no improvementRequire attributable telemetry; drop fixes the rerun doesn't confirm
Runaway spendLoop runs all night on low-value scenariosSpend budget per scenario; pause when rounds stop improving
Irreversible change slips throughAgent changes schema or storage format on its ownHard-to-undo changes need a person; tooling blocks them otherwise