Skip to content

fix(opencode): report persisted session cost - #383

Merged
goldmar merged 3 commits into
goldmar:mainfrom
torreyleonard:fix/opencode-session-cost
Jul 23, 2026
Merged

fix(opencode): report persisted session cost#383
goldmar merged 3 commits into
goldmar:mainfrom
torreyleonard:fix/opencode-session-cost

Conversation

@torreyleonard

Copy link
Copy Markdown
Contributor

Summary

  • fetch the completed OpenCode session and propagate its persisted cumulative cost
  • report cost for successful, failed, and interrupted turns when session data is available
  • preserve zero as a safe fallback when the session endpoint is unavailable
  • add regression coverage for non-zero OpenCode cost reporting

Why

The OpenCode harness currently hardcodes total_cost_usd: 0, so OCA reports $0.00 even when OpenCode's session ledger contains a real charge. In a live session, OpenCode persisted $41.5661305 while OCA displayed $0.00.

Verification

  • node scripts/run-tests.mjs tests/opencode-harness.test.ts (51 passed)
  • pnpm typecheck
  • pnpm build
  • pnpm check-static-guardrails
  • pnpm check-plugin-security

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown

Greptile Summary

This PR reports the persisted cost of completed OpenCode sessions. The main changes are:

  • Fetches the session ledger during turn completion.
  • Reports cost for completed, failed, and interrupted turns.
  • Uses a bounded lookup with zero as the fallback.
  • Deduplicates completion work across interruption and failure races.
  • Adds tests for cost reporting, timeout fallback, and interruption ordering.

Confidence Score: 5/5

This looks safe to merge.

The optional session lookup has a short timeout, competing completion paths share one session request, and interruption remains authoritative when it races with failure handling.

No blocking issues found in the changed code.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the opencode harness tests with a 120-second timeout; the run completed with exit code 0 in 3889 ms.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/harness/opencode.ts Reports validated persisted session cost with a bounded fallback and deduplicated completion handling.
tests/opencode-harness.test.ts Covers non-zero cost, unavailable session data, interruption ordering, and single-fetch behavior.

Reviews (6): Last reviewed commit: "fix(opencode): preserve interrupted outc..." | Re-trigger Greptile

Comment thread src/harness/opencode.ts Outdated
Comment thread src/harness/opencode.ts
@goldmar goldmar self-assigned this Jul 23, 2026
Comment thread src/harness/opencode.ts
@goldmar goldmar closed this Jul 23, 2026
@goldmar goldmar reopened this Jul 23, 2026
@goldmar
goldmar changed the base branch from main to agent/codeql-fork-policy July 23, 2026 04:29
@goldmar goldmar closed this Jul 23, 2026
@goldmar goldmar reopened this Jul 23, 2026
@goldmar
goldmar changed the base branch from agent/codeql-fork-policy to main July 23, 2026 04:32
@goldmar goldmar closed this Jul 23, 2026
@goldmar goldmar reopened this Jul 23, 2026
@goldmar
goldmar merged commit 51b004a into goldmar:main Jul 23, 2026
20 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.

2 participants