Repository navigation
Description
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:defaultvia 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.4resolvedDefault: 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.033535cost.total: 0.0340405cost.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:
-
If the route is truly subscription-backed:
OpenClaw should not surface API-style token-dollar cost as though it were authoritative spend. -
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:
/statusinterpretations- session-log parsers
COST_LOG.mdstyle cost workflows- any automation that assumes
usage.cost.totalis a trustworthy proxy for actual billed spend
Related / adjacent
- Docs/UX: Realtime Talk with OpenAI requires OpenAI Platform API credits, not Codex/ChatGPT subscription quota #76498 — Realtime Talk with OpenAI requires Platform API credits rather than Codex/ChatGPT subscription quota
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.estimatedusage.cost.billableusage.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.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 7, 2026
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:
canonicalCanonical: #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:
same_root_cause: fix(agents): zero usage cost for openai-codex OAuth sessions #78814 - Closed unmerged PR proposed zeroingopenai-codexOAuth costs for the same report, but current main solved the behavior through the native Codex path and cost aggregation changes.partial_overlap: [Bug]: gateway usage-cost reports $0 for codex/gpt-5.5 (zero cost table) — budget/spike monitoring is blind to API-key spend #85858 - Closed issue covered unknown zero pricing and usage-cost safeguards for Codex/API-key spend, which overlaps cost-trust handling but is not the subscription-billing semantics report.partial_overlap: [Feature]: Support official subscription/OAuth-backed model providers where available #84528 - Open umbrella request covers provider subscription/OAuth support and status clarity across providers; it is broader than this fixed Codex cost-log behavior.adjacent_distinct: Add session cost to /status output #64334 - Open request asks to display cumulative session cost in status output, which depends on cost fields but does not report the Codex OAuth nonzero billing bug.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-codextransport guards because current docs and migration policy use canonicalopenai/*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:
cost: ZERO_USAGE.cost, so Codex app-server turns do not persist nonzero per-token dollar cost. (extensions/codex/src/app-server/event-projector.ts:1809, 720c0ab372f3)extensions/codex/provider-catalog.ts:58, 720c0ab372f3)src/infra/session-cost-usage.ts:1191, 720c0ab372f3)openai/gpt-*refs and state that subscription profiles remove API keys from the spawned Codex process to avoid accidental API billing. Public docs:docs/plugins/codex-harness.md. (docs/plugins/codex-harness.md:58, 720c0ab372f3)../codex/sdk/typescript/src/events.ts:20, 636a2594c6f1)v2026.6.8contains the same native Codex zero-cost projection, unknown-pricing missing-cost handling, and Codex OAuth docs. (extensions/codex/src/app-server/event-projector.ts:1711, 844f405ac1be)Likely related people:
docs/plugins/codex-harness.md,extensions/codex/src/app-server/event-projector.ts,src/infra/session-cost-usage.ts)src/infra/session-cost-usage.ts,src/infra/session-cost-usage.test.ts)openai-codexOAuth 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)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.
barnacle-openclaw commentedon May 31, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.