Skip to content

Codex OAuth / ChatGPT subscription usage is recorded as per-token cost in session logs and COST_LOG-style workflows #78760

Closed

Description

@Wolverine971

Summary

When OpenClaw is using openai-codex/* through OpenAI Codex OAuth (ChatGPT/Codex subscription-style auth), local session usage records still populate message.usage.cost.* with nonzero per-token dollar values.

That makes local cost tracking workflows (for example parsing session JSONL or maintaining a COST_LOG.md) look like normal metered API billing, even when the user's expectation is that this route should be treated as subscription-backed usage semantics, not ordinary pay-per-token API spend.

This is confusing and can lead users to think they are being billed per token on a route they believe is covered by their ChatGPT/Codex subscription.

Environment

  • OpenClaw version: 2026.4.21
  • Platform: macOS
  • Provider/model route: openai-codex/gpt-5.4
  • Auth mode: openai-codex:default via OAuth
  • OAuth status: healthy / ok

What I observed

OpenClaw is correctly configured to use Codex OAuth and reports that auth as healthy:

  • defaultModel: openai-codex/gpt-5.4
  • resolvedDefault: openai-codex/gpt-5.4
  • auth profile: openai-codex:default (OAuth ...)
  • oauth status: ok

However, session JSONL records for actual openai-codex/gpt-5.4 turns contain nonzero cost fields such as:

"usage": {
  "input": 120568,
  "output": 72,
  "cacheRead": 2560,
  "cacheWrite": 0,
  "totalTokens": 123200,
  "cost": {
    "input": 0.30142,
    "output": 0.00108,
    "cacheRead": 0.00064,
    "cacheWrite": 0,
    "total": 0.30314
  }
}

Additional turns in the same session also recorded values like:

  • cost.total: 0.033535
  • cost.total: 0.0340405
  • cost.total: 0.2996525

So from the local runtime's perspective, Codex OAuth usage is being logged exactly like ordinary metered token billing.

Why this is a problem

Users reasonably interpret usage.cost.total as "this is what I am being charged."

For Codex OAuth / ChatGPT subscription-backed usage, that may be misleading in at least two possible ways:

  1. If the route is truly subscription-backed:
    OpenClaw should not surface API-style token-dollar cost as though it were authoritative spend.

  2. If the route is actually billable despite OAuth:
    OpenClaw should make that explicit in docs/UX, because many users assume ChatGPT/Codex OAuth means "not pay-per-token like normal API calls."

Either way, the current behavior creates confusion for:

  • /status interpretations
  • session-log parsers
  • COST_LOG.md style cost workflows
  • any automation that assumes usage.cost.total is a trustworthy proxy for actual billed spend

Related / adjacent

That issue is about Realtime Talk. This issue is about normal OpenClaw chat/model turns using openai-codex/* OAuth.

Expected behavior

One of these should happen explicitly:

Option A — Mark subscription-backed Codex OAuth usage as non-authoritative for billing

If openai-codex OAuth is intended to reflect ChatGPT/Codex subscription usage rather than direct per-token platform billing, then:

  • usage.cost.* should be omitted, zeroed, or marked as estimated/non-billable
  • docs should clearly explain that token usage may be recorded but dollar cost is not authoritative

Option B — Clearly document that Codex OAuth usage is still billed in token-dollar terms

If openai-codex/* OAuth truly maps to billable usage in the same cost sense as API-key usage, then:

  • docs should say so plainly
  • /status / logs should make clear this is real billable usage, not subscription-covered usage

Option C — Distinguish "estimated token-equivalent cost" from "actual billable cost"

For example by splitting fields such as:

  • usage.cost.estimated
  • usage.cost.billable
  • usage.billingMode: "subscription" | "metered_api" | "unknown"

Suggested improvement

Add a billing-mode concept for providers/auth paths, especially openai-codex OAuth, such as:

{
  "usage": {
    "billingMode": "subscription-backed-oauth",
    "cost": {
      "estimated": 0.30314,
      "authoritative": false
    }
  }
}

Or suppress dollar-cost entirely for subscription-backed paths and surface only token usage unless authoritative billing data is known.

Why this matters

This is a cost-trust / UX correctness issue.

Users are making real operational decisions from these logs:

  • whether to switch models
  • whether to disable cron jobs
  • whether OpenClaw is "unexpectedly costing money"

If Codex OAuth is special, OpenClaw should represent that clearly.
If it is not special, OpenClaw should document that clearly.

Right now it looks like API-metered spend even when the user believes they are using a ChatGPT/Codex subscription route.

Activity

  1. clawsweeper commented on May 7, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Close: current main and the latest release no longer log Codex subscription turns as nonzero per-token dollar spend; native Codex transcript usage carries zero dollar cost, unknown all-zero pricing is treated as missing cost for usage-cost aggregation, and docs route subscription users through Codex OAuth with API keys removed from the Codex child process.

    Root-cause cluster
    Relationship: canonical
    Canonical: #78760
    Summary: This issue is the canonical report for Codex OAuth cost-authority confusion; the same observable problem is now resolved on current main and release, while adjacent cost/status/subscription requests track distinct remaining product surfaces.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the shipped native Codex billing behavior: subscription-backed Codex turns should preserve token usage while avoiding authoritative per-token dollar spend, and direct API-key cost accounting should remain separate.

    Do we have a high-confidence way to reproduce the issue?

    No for current main: the old 2026.4.21 observation is credible, but current source shows native Codex turns emit zero dollar cost and usage-cost treats unknown all-zero pricing as missing rather than nonzero spend.

    Is this the best way to solve the issue?

    Yes. The implemented owner-boundary solution is better than reviving legacy openai-codex transport guards because current docs and migration policy use canonical openai/* refs with the Codex plugin while keeping API-key spend separate.

    Security review:

    Security review: No patch is under review; this is an ordinary provider billing-semantics issue, not a security-sensitive report.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Likely related people:

    • steipete: Recent history ties this person to the Codex provider unification, Codex harness docs, and the merged usage-cost fix that stopped confident zero-cost reporting for unknown pricing. (role: recent Codex and usage-cost contributor; confidence: high; commits: 4c33aaa86c16, 116c600f6011, d7363801d157; files: docs/plugins/codex-harness.md, extensions/codex/src/app-server/event-projector.ts, src/infra/session-cost-usage.ts)
    • MichaelZelbel: Authored the related merged usage-cost work that distinguishes unknown all-zero pricing from complete dollar spend, directly adjacent to this issue's cost-trust workflow. (role: recent related implementation contributor; confidence: high; commits: 1cc0a96df1a1, 6e8586916162, 16702496c67f; files: src/infra/session-cost-usage.ts, src/infra/session-cost-usage.test.ts)
    • hclsys: Opened the earlier closed PR that proposed zeroing openai-codex OAuth costs for this issue; that branch was not merged, but it is useful provenance for the reported behavior. (role: same-issue prior PR author; confidence: medium; commits: 6354a2f4098c, 3030307c893d; files: src/agents/openai-transport-stream.ts, src/agents/openai-transport-stream.test.ts)
    • vincentkoc: Local current-line blame in the shallow checkout points the normalized usage and cost surfaces to the recent storage metadata refactor, making this a weaker but relevant current-source routing signal. (role: current-source refactor contributor; confidence: low; commits: 1a3ded761e04; files: packages/llm-core/src/types.ts, src/utils/usage-format.ts, src/gateway/session-utils.fs.ts)

    Codex review notes: model internal, reasoning high; reviewed against 720c0ab372f3; fix evidence: release v2026.6.8, commit 844f405ac1be.

  2. barnacle-openclaw commented on May 31, 2026

    @barnacle-openclaw

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  3. added
    stale
    on May 31, 2026
  4. added
    P2
    impact:auth-provider
    impact:other
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:fix-shape-clear
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    on Jun 14, 2026
  5. locked as resolved and limited conversation to collaborators on Jun 25, 2026
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

    P2clawsweeper:fix-shape-clearclawsweeper:needs-maintainer-reviewclawsweeper:needs-product-decisionclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:auth-providerimpact:otherissue-rating: 🦞 diamond lobsterstale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions