Skip to content

OpenCode cost: a partial step sum must not be recorded as the run's authoritative provider cost #3960

Done

Description

@integry

From the review of #3959 (F1), in code that came from main with #3780.

Problem: applyOpenCodeCost / parseOpenCodeJsonl (packages/core/src/agents/impl/openCodeParsing.ts) skip a completed step whose cost is missing or invalid, without marking coverage incomplete. The remaining subtotal is returned as cost. OpenCodeAgent.buildExecutionResponse and evaluateOpenCodeAnalysis expose it as providerCostUsd, and calculateCost in llmMetrics.ts returns it directly, bypassing whole-run token pricing.

  • So a run with one priced step and one unpriced step is recorded with only the priced part.
  • If the priced step reports 0, the whole run is recorded as free.

Do:

  • Track cost coverage per distinct completed step. Return the step sum only when every such step has a valid cost; otherwise leave cost undefined unless a valid cumulative result total exists.
  • Keep the duplicate-step handling and the explicit-zero semantics.
  • Update the test "sums known step costs when other steps have missing or invalid costs": it should now expect undefined, so token pricing applies. Add a test where a priced 0 step plus an unpriced step does not record the run as free.
  • Small cleanup (review S1 from Merge main into the runtime epic (OpenCode cost + detail persistence) #3959): remove the duplicate providerCostUsd assignments in failedAgentExecution.ts.

Activity

  1. propr-dev commented on Dec 1, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using codex agent with gpt-6.2-sol model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-6.2-sol
    • Branch: 3960/gpt-6.2-sol-opencode-cost-a-partial-s-20261201-1126-jrk
    • Base Branch: 3758-epic-runtime-abstraction-sc0
    • Worktree: issue-3960-20261201-1126-gpt-6.2-sol-jrk

    🔍 Track Task Execution

  2. integry commented on Dec 1, 2026

    @integry
    OwnerAuthor

    Done in #3961, which merged into the runtime epic; the epic merged into main with #3774 and ships in 0.9.4.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions