Skip to content

Ultra-mode Terra and Sol sessions can overcount forked context #2037

Description

@iam-brain

CodexBar appears to overstate usage for gpt-5.6-terra and especially gpt-5.6-sol when they run in Ultra mode.

The pricing is correct: models.dev reports the correct input, cached-input, output, and long-context rates for these models. The inflation seems to be coming from usage accounting. Ultra sessions can fork multiple agents and replay large portions of the parent context while interleaving cumulative token snapshots.

In one local Sol session, the raw log reached roughly 268M cumulative input tokens, while CodexBar attributed 3.29B input tokens and about $4,000 of standard cost. A single forked turn contributed more than 3B tokens across hundreds of rows. The cache marked the file as having divergent totals, which is consistent with multiple cumulative-token lineages being mixed together.

Potential fixes include:

  • Keep cumulative-token baselines scoped per task/turn or fork lineage.
  • Detect fork/replay boundaries and avoid treating replayed parent context as new usage.
  • Prefer last_token_usage deltas only when cumulative totals are unavailable or trustworthy; otherwise use cumulative deltas per lineage.
  • Add a guardrail that rejects implausibly large deltas relative to the reported per-turn usage.

The goal is to preserve genuine Ultra usage while preventing replayed fork context from being counted repeatedly. This is may be related to #1062 and #1138, but appears to be a distinct current failure involving interleaved Ultra-mode task counters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions