Skip to content

opencode export --pure is not safe as a billing ledger for long sessions #21780

Closed as duplicate

Description

@rosspeoples

Summary

In ORPT-Bench we found that opencode export <sessionID> --pure is not reliable enough to use as the source of truth for session cost accounting.

For at least one reproduced session, the live OpenCode SQLite message table retained the full assistant message ledger with per-message cost values, while opencode export --pure for the same live session failed with truncated output (parse error: Unfinished string at EOF). In earlier benchmark runs, we also observed materially undercounted session totals when relying on export-derived message costs.

This is a billing-integrity problem, not just a display problem.

Why this matters

ORPT-Bench uses actual observed cost as a first-class scoring input. If export undercounts or becomes unparsable on larger sessions, any downstream benchmarking, reporting, or spend controls built on top of export can be wrong by a meaningful amount.

Repro evidence

Fresh reproduced session inside the runner container:

  • Session ID: ses_28baacfedffeeTgtD3rTkPB8Gx
  • Title: 08-workspace-transplant-bundle-repair:opencode/gpt-5.4-nano

Querying the live SQLite message ledger through opencode db shows many assistant rows with nontrivial data.cost values for this single session, for example:

  • 0.00213322
  • 0.00069746
  • 0.00074161
  • 0.00067461
  • 0.00083544
  • 0.00096357
  • 0.00174475
  • 0.00242191
  • and more

Summing those assistant message costs for the session yields:

  • 0.01513360

The session has no parent session (parent_id = null), so this is not a parent/child session accounting confusion.

But exporting the exact same live session via:

opencode export ses_28baacfedffeeTgtD3rTkPB8Gx --pure

then parsing with jq failed with:

parse error: Unfinished string at EOF

So the export stream for this live session was not even parseable as complete JSON.

Expected behavior

One of these needs to be true:

  1. opencode export --pure should return a complete, parseable session payload for long sessions.
  2. The exported payload should preserve the full billed assistant message ledger used internally.
  3. There should be a documented supported way to retrieve exact billed session/message costs safely for automation.

Actual behavior

  • The live message ledger contains assistant cost values.
  • opencode export --pure can fail or produce output that is not safe to treat as a billing ledger.
  • Downstream tooling can materially undercount spend if it trusts export alone.

Downstream mitigation

As a mitigation, we are switching our benchmark harness to read exact assistant message costs directly from the live OpenCode SQLite message ledger for the target session, and using export only as a fallback/debug source.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 9, 2026
  2. github-actions commented on Apr 9, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use one of the three required templates: Bug Report, Feature Request, or Question. This appears to be a bug report, so please use the Bug Report template which requires a Description field and reproduction steps in the expected format.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions