Skip to content

Give the timeline whole-item closure a byte budget #1517

Closed as not planned
Closed as not planned

Description

@SawyerHood

⚠ Agent-generated: An AI agent found this while addressing review findings on #1510. Please
verify details before you act on them.

Summary

ensureSequenceWindowWholeItemRows reads the backfill rows for the items a
window owns before any caller can check their size. A large lifecycle row or a
long unfinished-text prefix therefore enters memory first, and the four-megabyte
limit applies only afterwards.

Why it happens

The byte floor (findStoredTimelineWindowByteBudgetFloor) measures the window
in SQL and never reads the payloads it rejects. Closure has no equivalent step.
It calls listStoredItemLifecycleRowsByItems and
listStoredBufferedTextDeltaRowsByItems directly, so the rows arrive in memory
before their bytes are known.

An inline-output cap does not bound this. The cap shortens
aggregatedOutput, result, and resultText. It never shortens a command
line, so one large command field arrives whole.

Where it applies

Both callers share the behavior:

For the details route the response can also grow, though only through the
unfinished-text prefix, and only for an item left unfinished inside a turn that
did finish. Lifecycle backfill does not grow the response, because the
projection merges item/started into the same row as item/completed.

Suggested fix

Give the helper a byte budget, and add a SQL-side count for the backfill rows
that mirrors getStoredEventRowsByParentToolCallIdsDataBytes. Then a caller can
ask for a bounded closure instead of measuring what it already holds.

The budget must never drop an item's only start row. #1510 tried the simple
version of that and made interrupted commands disappear, so a bounded closure
needs to keep a start representation for every item it keeps.

Origin

Raised by the automated review on
#1510 as a P2, and split out because the fix
belongs in the shared helper and changes the timeline page as well.

AGENT GENERATED: by Claude Opus 5

Activity

  1. SawyerHood commented on Aug 13, 2026

    @SawyerHood
    CollaboratorAuthor

    Closing. This was filed automatically by an agent during the 13 Aug 2026 issue sweep as a follow-up to a pull request. Sawyer is closing the sweep follow-ups rather than carrying them as backlog.

    The analysis above stands on its own and is preserved here. Reopen if it becomes relevant.

    AGENT GENERATED: by Claude Opus 5

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