Skip to content

fix: aggregate OpenCode usage across completed steps - #30

Merged
RobertTLange merged 2 commits into
mainfrom
fix/opencode-step-usage
Sep 8, 2026
Merged

fix: aggregate OpenCode usage across completed steps#30
RobertTLange merged 2 commits into
mainfrom
fix/opencode-step-usage

Conversation

@RobertTLange

@RobertTLange RobertTLange commented Sep 8, 2026

Copy link
Copy Markdown
Owner

OpenCode emits per-step usage, but Headless previously retained only the last step. Two completed steps costing $1 and $2 now report $3, with all input, output, reasoning, and cache tokens included.

Completed steps are deduplicated by session/message/part identity and retained independently of the rolling text trace, so long --json --usage runs preserve earlier charges. The accumulator retains numeric usage and bounded identity data. Missing native costs fall back to estimated pricing for all recorded tokens, including separate reasoning output. The public usage schema is unchanged.

Validation:

  • Regression tests reproduce last-step-only totals and eviction after more than 256 KiB of streamed output; both now pass.
  • Tests cover repeated snapshots, anonymous steps, missing/invalid costs, zero usage, cache/reasoning tokens, and oversized identities.
  • Focused parser/CLI tests, TypeScript build, and package check pass. Full local npm run check passes with an isolated temporary HOME and umask 0077; PR CI is checked before merge.
  • Downstream agentic-scientist regression confirms the normalized total imports exactly once and repeated ingestion is idempotent.

DeepSeek tariff updates and interrupted-run recovery are separate follow-ups.

A separate test-only commit makes the existing run-wait transcript fixture timestamp deterministic. Filesystem timestamp precision could otherwise make the fixture appear older than its run and hang the suite.

@RobertTLange
RobertTLange merged commit 6353a89 into main Sep 8, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant