Skip to content

agent: mid-turn compaction (a single turn that grows past the budget) #7

Closed

Description

@panyam

Follow-up to issue 939. The SummarizingCompactor fires once, at the top of a turn, on the incoming history (via RunnerConfig.Compactor). That covers the common case (a long conversation), but not a single turn that itself balloons past the context budget mid-loop — e.g. many parallel tool calls returning large results within one turn.

Scope

  • Re-check the estimate inside the Runner loop (between steps) and re-run the Compactor on the working msgs when it crosses the budget, emitting another EventCompaction.
  • Decide the interaction with tool-result offloading (966): offloading already shrinks large tool outputs to stubs, so mid-turn compaction is the fallback for when even the stubs + assistant text exceed budget.
  • Guard against a compaction/So-still-too-big loop (a hard floor; abort the turn with a clear error if a single step can't fit).

Roadmap notes this as the "L for mid-turn" effort. The pre-loop hook shipped in 939 is the "M" version.

Activity

  1. transferred this issue frompanyam/mcpkiton Aug 22, 2026
  2. added
    P2Planned, has a consumer, not urgent
    on Oct 14, 2026
  3. panyam commented on Oct 15, 2026

    @panyam
    OwnerAuthor

    Data point from dogfood run 1 (#57): DeepSeek used 155k input tokens over 8 steps answering a single 'where is X built' question, mostly from read_file returning whole files (main.go, config.go, app.go, connections.go) that then rode along in every later step. Mid-turn compaction would bound that; so would read_file defaulting to a window.

  4. panyam commented on Oct 26, 2026

    @panyam
    OwnerAuthor

    Folding #109's last item in here, as agreed: make the step budget visible to the model ("step 31 of 40"). It needs the before-each-model-call point, so it'll be one of the first stages on the step chain this PR adds. See docs/HOOKS.md (#125).

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

    P2Planned, has a consumer, not urgentmission_dogfood_codingServes the dogfood_coding mission

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions