Skip to content

Price a resumed Codex thread once, at its newest leg - #505

Merged
renmengye merged 4 commits into
mainfrom
fix/session-cost-per-leg
Oct 11, 2026
Merged

renmengye merged 4 commits into
mainfrom
fix/session-cost-per-leg

Conversation

@renmengye

@renmengye renmengye commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #479.

A session that sleeps and resumes writes one record per leg. For Codex (exec resume) each leg's usage is the whole thread's cumulative total. Claude Code has also been cumulative since 2.1.277, but the CLI version that ran a session is not recorded and an override can pin an older CLI, so Claude legs keep summing (an overstatement, never an undercount). session_totals summed every leg, so outerloop status overstated a resumed session by about the number of legs. Hermes starts a fresh process per leg, so its legs are per invocation and still sum.

  • Index entries now record backend and session_id. Totals keep only the newest indexed leg of each Codex session (CUMULATIVE_BACKENDS), and everything else sums as before.
  • Compatibility: the schema version is unchanged and older kernels ignore the extra keys. Entries written before this change have no session id and keep contributing their recorded cost, so sessions captured before the upgrade still overstate (stated in the Upgrading: line).
  • No cap or budget reads these totals; they are reporting only.
  • docs/session-capture.md corrected: it said resumed usage came from the current invocation only.

One behavior test: three cumulative legs total to the last leg's cost.

Built by GLM-5.3 (self-reviewed), reviewed by Codex (it found Claude Code is cumulative too, confirmed against Claude Code's changelog, fixed in e67053d), final read by Claude Opus 5.5.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 1 — reviewed head e67053de — reviewer summarizer:hermes/gpt-5.6-terra over coverage+credentials+deployment+general+lifecycle+prose.

terra
Advisory findings from outerloop — the code owner decides. Reply to disagree; the outerloop:no-review label opts this PR out.

Verdict: 1 blocking, 0 advisory.

1 finding attached to the lines below.

One blocking finding recorded: older Claude version overrides cause resumed-session totals to undercount. Rejected: none.

Comment thread src/outerloop/session_evidence.py Outdated
@renmengye renmengye changed the title Price a resumed Claude or Codex session once, at its newest leg Price a resumed Codex thread once, at its newest leg Oct 11, 2026
@renmengye renmengye added the outerloop:review re-request the advisory review label Oct 11, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2 — reviewed head f9374abe — reviewer hermes/gpt-5.6-terra.

terra
Advisory findings from outerloop — the code owner decides. Reply to disagree; the outerloop:no-review label opts this PR out.

Verdict: no defects found.

@renmengye
renmengye merged commit b117315 into main Oct 11, 2026
5 checks passed
@renmengye
renmengye deleted the fix/session-cost-per-leg branch October 11, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

outerloop:review re-request the advisory review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session cost totals sum cumulative per-leg token counts for resumed sessions

1 participant