Skip to content

Add context-hygiene at phase boundaries: compressed plan restatement and abort budget #19

Closed

Description

@dmccoystephenson

Problem

Empirical evidence: autonomous agent success decays exponentially with task length, and the dominant practical failure in long runs is now context rot — quality degradation as input grows, even when the context window isn't full. The current template has 10 phases with no compression at boundaries; accumulated tool output and prior reasoning travel intact through the whole loop.

Motivation

Per RESEARCH.md §4 — Long-horizon agent runs decay exponentially; context rot is the practical limit:

  • Ord 2025 (arXiv:2505.05115): constant per-minute failure hazard → exponential decay with task length.
  • Chroma "Context Rot" 2025 (research.trychroma.com/context-rot): 18 frontier models tested. 20–50% accuracy drop from 10k → 100k+ tokens, even when window isn't full. Models perform better on shuffled haystacks than coherent ones.
  • Anthropic, Effective context engineering for AI agents (first-party).

Confidence: high.

Proposal

Two changes:

1. Compressed plan restatement at phase boundaries

At each major boundary (triage → implementation → PR → merge → self-audit), the agent restates in a tight, structured form:

  • Which issues are in scope
  • Which files will be / were touched
  • What invariants must hold

Subsequent phases work from this summary, not the full accumulated transcript. This is consistent with Anthropic's effective-context-engineering guidance.

2. Abort-and-file-gap-issue budget

If the loop hasn't converged after N tool calls or M tokens (numbers to calibrate empirically — start with 500 tool calls / 200k tokens as a placeholder), the agent aborts the current PR, files a gap issue describing what was attempted and why it didn't converge, and exits. The half-life model predicts persistence past a budget is strictly worse than restart with fresh context.

Acceptance criteria

  • Phase 2 ends with a "Plan summary" block to be re-read at the start of Phase 3
  • Phase 3 ends with an "Implementation summary" block to be re-read at Phase 4
  • Phase 8 ends with a "Cycle summary" block to be re-read at Phase 9
  • An abort-budget edge case added to Edge cases section, with explicit thresholds
  • Aborted cycles produce a gap issue with a specific template

Open question

Whether to use ScheduleWakeup with a fresh-context restart when an abort fires. The harness supports this; the dev-loop skill could be authored to handle it.

Retrofit

Per CLAUDE.md's promotion rule, retrofit PRs needed for all four child skills.

Related


drafted by Claude on behalf of Daniel Stephenson

Activity

  1. added a commit that references this issue on May 25, 2026
    38e058b
  2. added a commit that references this issue on Aug 3, 2026
    7b09baf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions