Context Churn & The Loop of Sisyphus: Auditing AI Agent Thrash
In ancient Greek mythology, King Sisyphus rolled a colossal boulder up a hill, only to watch it roll back down.
In modern agentic software development, engineering teams pay frontier LLMs to repeat that cycle hundreds of times per sprint.
We call this phenomenon Context Churn.
It occurs when an autonomous coding agent, confronted with contradictory requirements, unstated dependencies, or hidden side-effects, enters an oscillating loop of self-correction:
- Agent implements Feature A in
auth.ts. - Existing unit test fails in
billing.ts. - Agent modifies
billing.tsto satisfy Feature A, inadvertently breakingtenant.ts. - Agent attempts to fix
tenant.ts, forgets initial constraints from Step 1, and revertsauth.ts. - The cycle repeats until context limits trigger compaction or maximum tool calls exhaust the budget.
[TELEMETRY STREAM // LOOP OSCILLATION DETECTED]
File: src/services/auth.ts (Modified: 14 times across 22 turns)
File: src/services/billing.ts (Modified: 11 times across 22 turns)
Net Code Delta: +18 lines (Gross code churn: 1,420 lines modified / reverted)
Total Token Ingestion: 340,000 tokens
Cost Incurred: $10.20 for an 18-line diff
Verdict: REPETITIVE CONTEXT THRASHING
To traditional project management tools, this sprint task looked active and healthy: commits appeared every four minutes. In reality, the agent was stuck in a feedback loop.
The Anatomy of Agent Thrash
Why do autonomous agents thrash? Through telemetry audits across hundreds of repositories, agent churn traces back to three structural failures:
1. Inverted Feedback Signals
When human developers get stuck, they step back, ask a colleague for clarification, or challenge the ticket requirements.
An LLM agent cannot challenge ambiguous human intent unless explicitly instructed to stop. Instead, it assumes the specification is absolute ground truth and the test harness is broken. It begins mutating surrounding codebase infrastructure: mocking away failing tests, creating redundant wrappers, or silently disabling type checkers.
2. Cascading Context Compaction
As the conversation transcript grows beyond 60,000 tokens, system prompts and original acceptance criteria suffer from attention decay. The agent prioritizes the most recent compiler error message over the original architectural design.
3. Missing Structural Guardrails
Without deterministic linters and immutable database contracts, the agent treats your entire codebase as malleable clay. Providing an agent-ready internal developer platform with isolated database branches prevents speculative migrations from polluting shared environments.
Auditing Churn with Continuous Telemetry
RetroAgile replaces passive burndowns with real-time Agent Churn Indexes. By streaming Git commits and AST diffs directly into our telemetry pipeline, we track:
- Touch Frequency / File Ratio: A healthy agent feature branch touches a file 1.2 to 2.1 times. Any ratio above 4.0 indicates circular thrashing.
- Reversion Velocity: The rate at which an agent undoes its own previous tool calls within the same branch.
- Review Turnaround Latency: Measuring how long human architects take to approve modular sub-PRs versus monolithic diffs.
// Telemetry Churn Formula
export function calculateChurnIndex(branchEvents: GitTelemetryEvent[]): number {
const touchesByFile = groupTouches(branchEvents);
const reverts = detectReversions(branchEvents);
const thrashScore = Object.values(touchesByFile).reduce((acc, count) => {
return acc + (count > 2 ? Math.pow(count - 2, 1.8) : 0);
}, 0);
return normalizeScore(thrashScore + reverts.length * 2.5);
}
When an agent's Churn Index crosses the warning threshold, RetroAgile automatically triggers a circuit breaker, halts the autonomous task, and notifies the human architect with exact telemetry on where the specification stalled.
The Solution: Circuit Breakers & Atomic Scopes
How do you eliminate context churn permanently?
- Max Re-touch Quotas: Restrict agents to a maximum of 3 edits per file per sub-task. If a test is not passing after 3 iterations, the problem is not syntax—it is architecture.
- Atomic Contract PRs: Never task an agent with building an entire subsystem in one pass. Task it with defining the database schema and GraphPG subscription interface first, then implement the worker in an isolated sub-PR. Pair contracts with spec-readiness scoring and agentic DORA metrics to evaluate delivery health.
- Continuous Retrospective Audits: Review your sprint's Churn Index every Friday. If one module consistently induces agent thrash, that module has architectural debt that needs human refactoring.
Stop paying for LLM circular reasoning. Audit agent telemetry, enforce circuit breakers, and keep your agents moving forward.