Usage & Spend: route provider "nous" in OpenCodexRouteDispatcher so Nous-ledger entries surface as spend
Summary
PR #3376 added the Nous Portal quota provider, and UsageProvider already has a .nous case. But the OpenCodex spend path drops Nous entries: OpenCodexRouteDispatcher.route(provider:) only maps openai, opencode-go, kimi-coding/kimi-for-coding, deepseek, and opencode/opencode-free. A provider: "nous" entry falls to .unknown and is silently filtered out by the spend fan-out (guard case let .subscription(provider)), so Usage & Spend can never surface Nous cost.
Proposed change (one line)
Sources/CodexBarCore/Vendored/OpenCodexUsage/OpenCodexRouteDispatcher.swift:
case "nous":
.subscription(.nous)
No other changes appear to be required: the JSONL parser accepts arbitrary provider strings, UsageProvider.nous already exists (Sources/CodexBarCore/Providers/Providers.swift), and the fan-out resolves pricing from the models.dev catalog by model string, falling back to the existing unpriced/partial-data handling where coverage is missing.
Real-world data behind this
I run Hermes Agent on a Nous Portal subscription and built a local, read-only ledger that emits Hermes's own session usage records into ~/.opencodex/usage.jsonl in the OpenCodex entry schema (verified against OpenCodexUsageParser on main: requestId / epoch timestamp / provider / model / usageStatus: "estimated" / usage.{inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, reasoningOutputTokens, totalTokens}). Current contents: 23 entries across z-ai/glm-5.3-flash, anthropic/claude-sonnet-4.6, deepseek/deepseek-v4-flash-0731, and stepfun/step-3.7-flash:free — all dropped by the router today. Happy to provide redacted sample entries.
Two notes for whoever picks this up:
- Estimate basis: entries are
usageStatus: "estimated"(Hermes prices via its provider models catalog). Portal-metered spend (credits) will differ from list-price estimates — same caveat as other estimated sources. - models.dev coverage:
anthropic/*anddeepseek/*should price directly;z-ai/glm-*depends on the catalog's z.ai entry. Unpriced models degrade to token-mix-only rows per the existing partial-data rules, which is fine.
Environment
- CodexBar
main(verified against currentOpenCodexRouteDispatcher.swift/Providers.swiftsources) - Ledger produced outside OpenCodex-the-tool, purely in its documented
usage.jsonlformat
Codex review: this still needs some work. Reviewed September 25, 2026, 6:54 PM ET / 22:54 UTC.
Summary
The request remains useful. The merged Nous Portal provider supplies quota and credit balances, while current main and v0.66.0 still omit nous from OpenCodex spend routing. The proposed mapping would admit ledger entries, but its pricing and attribution need a maintainer decision before the change can reliably show spend.
Reproducibility: yes. for the routing gap: current source deterministically sends provider: "nous" to the unknown route and the fan-out drops it. The reporter's private ledger was not executed here.
Maintainer decision needed
| Question | Recommendation |
|---|---|
Should externally produced OpenCodex-format records labeled nous populate the Nous spend row even when their model prices are unavailable or differ from Portal credit charges? |
Allow labeled estimates: Accept the local ledger as an opt-in Nous activity source and label its priced and unpriced rows separately from Portal credits. |
Why: The existing Nous integration reports Portal balances, while the requested ledger is a separate user-produced estimate with a different accounting basis.
Next step A maintainer should settle whether user-produced Nous ledger estimates belong alongside Portal balances before a focused implementation is routed.
Review details
Best possible solution:
Define Nous ledger attribution and estimated-price labeling, then add a focused route and dashboard test using redacted records; leave unavailable prices visibly unpriced.
Do we have a high-confidence way to reproduce the issue?
Yes for the routing gap: current source deterministically sends provider: "nous" to the unknown route and the fan-out drops it. The reporter's private ledger was not executed here.
Is this the best way to solve the issue?
No, the proposed one-line route alone does not establish dollar spend. The pricing lookup and distinction between list-price estimates and Portal credits need an explicit contract and focused coverage.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
- The one-line route can publish token activity without a dollar estimate: pricing looks up
nousplus the recorded model ID, and cross-vendor model prefixes do not automatically select those vendors' rates. - The product contract needs to distinguish estimated list-price ledger spend from Nous Portal's metered credit balances.
Codex review notes: model internal, reasoning medium; reviewed against bab389fea982.
Label changes
Label changes:
- add
P2: The missing route affects a bounded, opt-in local spend workflow rather than core app availability. - add
impact:other: Nous ledger activity is omitted from the provider spend view, an accounting visibility gap outside the specific impact categories. - add
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label. - add
clawsweeper:source-repro: Current issue advisory state selects this label. - add
clawsweeper:no-new-fix-pr: Current issue advisory state selects this label. - add
clawsweeper:needs-maintainer-review: Current issue advisory state selects this label. - add
clawsweeper:needs-product-decision: Current issue advisory state selects this label.
Label justifications:
P2: The missing route affects a bounded, opt-in local spend workflow rather than core app availability.impact:other: Nous ledger activity is omitted from the provider spend view, an accounting visibility gap outside the specific impact categories.
Evidence reviewed
What I checked:
- Current routing gap: The route switch has no nous case and returns unknown for unlisted providers. (
Sources/CodexBarCore/Vendored/OpenCodexUsage/OpenCodexRouteDispatcher.swift:12, bab389fea982) - Dashboard filter: The spend fan-out retains only subscription routes, so an unknown Nous route produces no provider snapshot. (
Sources/CodexBarCore/Vendored/OpenCodexUsage/OpenCodexUsageFanOut.swift:13, bab389fea982) - Parser accepts the record: Parsing requires a nonempty provider string but does not restrict it to known route names. (
Sources/CodexBarCore/Vendored/OpenCodexUsage/OpenCodexUsageParser.swift:255, bab389fea982) - Pricing boundary: Pricing keeps the recorded provider identity; the resolver retains an
anthropic/model prefix under providernousinstead of automatically using Anthropic's rates. (Sources/CodexBarCore/Vendored/CostUsage/ModelsDevPricingTargetResolver.swift:38, bab389fea982) - Existing Nous scope: The existing Nous descriptor is registered, but declares token cost unsupported; its documented data source supplies portal balances, not a local request ledger. (
Sources/CodexBarCore/Providers/Nous/NousProviderDescriptor.swift:56, bab389fea982) - Related merged work: https://github.com/steipete/CodexBar/pull/3376 merged Nous Portal quota and credit support on 2026-09-18; it does not claim OpenCodex ledger spend support. (88aab2ba6a25)
Likely related people:
- Chipagosfinest: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
- Asis Panda: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
How this review workflow works
- ClawSweeper keeps one durable marker-backed review comment per issue or PR.
- Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
- A fresh review can be triggered by eligible
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch. - PR/issue authors and users with repository write access can comment
@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
- Maintainer-only repair and merge flows require explicit commands such as
@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review. - Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.
Reporter here — answering the two open product questions with data, since I'm the one producing the ledger.
1. The product contract (my position as reporter)
Allow labeled estimates — with one hard line: ledger estimates must never be presented as Portal-metered credits.
Concretely:
- The Nous quota card (PR #3376) stays the only surface for Portal balances/credits.
- Ledger-derived spend appears only in Usage & Spend, as
estimated(list-price basis), with provenance already carried bysourceKind: .openCodexso it can't be confused with the Portal integration. - Rows whose models have no pricing resolve to the existing unpriced/token-mix-only display — never a fabricated dollar figure.
- If it's cleaner, gate the spend row behind the existing "OpenCodex usage logs" toggle (it already is, structurally) so it's strictly opt-in.
If that contract is acceptable, I agree the implementation should be more than the one-liner: a focused route + dashboard test with redacted records, as the review suggests.
2. The pricing boundary — here is the actual data
The review is right that the one-line route alone doesn't establish dollar spend, because pricing looks up nous + the recorded model ID with no cross-vendor prefix fallback. Here is my full ledger aggregated per model (Hermes's own per-session usage records; estUSD = Hermes's estimate from its provider models catalog — which is Nous's own models-API pricing, i.e. the promo/promotional rates Nous actually meters at, not vanilla vendor list prices):
| model | calls | input | output | cacheRead | cacheWrite | reasoning | estUSD |
|---|---|---|---|---|---|---|---|
| anthropic/claude-opus-4.6 | 12 | 390,811 | 29,658 | 0 | 0 | 0 | 2.6955 |
| anthropic/claude-opus-4.8 | 118 | 1,359,171 | 146,903 | 7,811,132 | 1,336,574 | 0 | 21.5112 |
| anthropic/claude-sonnet-4.6 | 4 | 89,768 | 114 | 0 | 0 | 0 | 0.2710 |
| deepseek/deepseek-v4-flash-0731 | 535 | 2,086,252 | 380,657 | 162,712,704 | 0 | 245,138 | 0.0285 |
| deepseek/deepseek-v4-flash:free | 34 | 875,795 | 18,503 | 987,520 | 0 | 0 | 0.0000 |
| deepseek/deepseek-v4-pro | 204 | 1,103,536 | 90,962 | 14,177,536 | 0 | 22,195 | 0.8783 |
| grok-4.3 | 62 | 567,888 | 23,856 | 3,725,184 | 0 | 1,037 | 0.0000 |
| nvidia/nemotron-3-ultra:free | 30 | 214,899 | 2,751 | 662,144 | 0 | 0 | 0.0000 |
| stealth/ox-alpha | 2 | 29,662 | 156 | 256 | 0 | 0 | 0.0000 |
| stepfun/step-3.7-flash:free | 108 | 93,741 | 227,620 | 1,024 | 0 | 0 | 0.0000 |
| z-ai/glm-5.3-flash | 1 | 28,341 | 77 | 3,520 | 0 | 66 | 0.0018 |
Notes relevant to the pricing decision:
- Model IDs above are exactly the IDs served by Nous's inference API (
GET /v1/models), so a models.devnousprovider entry can mirror those IDs 1:1 and make thenous+ model-ID lookup deterministic. - Four of the eleven models are free/promo tiers with no meaningful rate — they are the concrete "visibly unpriced" cases and should stay token-mix-only.
- Where Hermes has estimates, they reflect Nous's promo pricing (e.g.
deepseek-v4-flash-0731: 165M tokens at $0.0285) — noticeably below vanilla vendor list prices, which is why I'd oppose falling back to cross-vendor vendor rates: it would overstate spend relative to what the Portal actually meters.
3. Redacted sample entries (parser-schema fixtures)
{"requestId":"nous-8f5e10c605cbdfc1","timestamp":1777362346.46,"provider":"nous","model":"anthropic/claude-sonnet-4.6","usageStatus":"estimated","usage":{"inputTokens":22411,"outputTokens":5,"cacheReadInputTokens":0,"cacheCreationInputTokens":0,"reasoningOutputTokens":0,"totalTokens":22416},"surface":"hermes-gateway"}
{"requestId":"nous-4a1d7c2e9b0f83a6","timestamp":1788143082.41,"provider":"nous","model":"z-ai/glm-5.3-flash","usageStatus":"estimated","usage":{"inputTokens":28341,"outputTokens":77,"cacheReadInputTokens":3520,"cacheCreationInputTokens":0,"reasoningOutputTokens":66,"totalTokens":31998},"surface":"hermes-gateway"}
{"requestId":"nous-c3f9d2b7e5a64108","timestamp":1785982323.12,"provider":"nous","model":"deepseek/deepseek-v4-flash-0731","usageStatus":"estimated","usage":{"inputTokens":754741,"outputTokens":28710,"cacheReadInputTokens":7528192,"cacheCreationInputTokens":0,"reasoningOutputTokens":17239,"totalTokens":8303882},"surface":"hermes-gateway"}
(conversationID and a _meta extension block omitted here; both are ignored by the parser — happy to provide the unredacted private ledger to a maintainer on request.)
4. One more touchpoint
NousProviderDescriptor currently declares token cost unsupported. If the maintainer green-lights the "allow labeled estimates" contract, that flag needs to flip (or the spend source stays separate with its own descriptor) — flagging so it doesn't get missed.
Per the no-new-fix-pr label I have not opened a PR; happy to supply test fixtures, the full redacted ledger, or implement behind the maintainer's preferred contract once the decision lands.
Thanks @Reztahla. Confirmed from the code: OpenCodexRouteDispatcher has no nous case, so Nous entries in an OpenCodex-format ledger are dropped from the subscription fan-out, and the Nous provider currently declares no token-cost support. Before adding the route I need to know what actually writes those entries: a sanitized usage.jsonl sample (a few lines, keys and cost fields intact, values redacted) or a pointer to the producer's source would establish the provider key and cost attribution so the route lands with parser and fan-out coverage rather than a guess. Keeping this open for that.
Thanks @steipete — here's both the producer source and sanitized samples.
Producer
The entries are written by a small local read-only extractor (not the OpenCodex tool). Full source: https://gist.github.com/Reztahla/71b59185ba468d6ef08a16571788f5b2
What it does, precisely:
- Source of truth: Hermes Agent's local session ledger —
~/.hermes/state.db, tablesession_model_usage(opened with SQLitemode=ro; the DB is never written). - Emits one entry per
(session_id, model)row wherebilling_provider = 'nous'and the row has traffic. - Field mapping:
timestamp←first_seen(epoch seconds),usagetokens ← the row'sinput_tokens/output_tokens/cache_read_tokens/cache_write_tokens/reasoning_tokens,conversationID←session_id. - The file is fully rewritten each run, so it's idempotent and self-backfilling.
Cost attribution — the important caveat
The standard OpenCodex entry schema carries no cost field, and my ledger does not invent one for the parser. Specifically:
usageStatusis always"estimated"— the basis is Hermes's per-session cost estimates, whosecost_sourceisprovider_models_api(i.e., priced from Nous's own models-API catalog, which reflects the promotional rates Nous actually meters at).- The only cost-ish data rides in a non-standard
_metaextension (hermesEstimatedCostUSD,costSource,apiCalls) which the parser ignores. It exists so the data isn't lost, not as a pricing contract. If upstream prefers,_metacan be dropped entirely — CodexBar's own models.dev-based pricing is the intended dollar surface. - So for route design: expect token-only entries with
usageStatus: "estimated", dollar figures computed by CodexBar's pricing (or left unpriced), and no metered-credit data — Portal credits remain the separate #3376 surface.
Sanitized samples (keys intact, values redacted)
{"requestId":"nous-XXXXXXXXXXXXXXXX","timestamp":1777362346.46,"provider":"nous","model":"anthropic/claude-sonnet-4.6","usageStatus":"estimated","usage":{"inputTokens":22411,"outputTokens":5,"cacheReadInputTokens":0,"cacheCreationInputTokens":0,"reasoningOutputTokens":0,"totalTokens":22416},"surface":"hermes-gateway","_meta":{"apiCalls":1,"hermesEstimatedCostUSD":0.067,"costSource":"provider_models_api"}}
{"requestId":"nous-XXXXXXXXXXXXXXXX","timestamp":1788143082.41,"provider":"nous","model":"z-ai/glm-5.3-flash","usageStatus":"estimated","usage":{"inputTokens":28341,"outputTokens":77,"cacheReadInputTokens":3520,"cacheCreationInputTokens":0,"reasoningOutputTokens":66,"totalTokens":31998},"surface":"hermes-gateway","_meta":{"apiCalls":1,"hermesEstimatedCostUSD":0.002,"costSource":"provider_models_api"}}
{"requestId":"nous-XXXXXXXXXXXXXXXX","timestamp":1785982323.12,"provider":"nous","model":"deepseek/deepseek-v4-flash-0731","usageStatus":"estimated","usage":{"inputTokens":754741,"outputTokens":28710,"cacheReadInputTokens":7528192,"cacheCreationInputTokens":0,"reasoningOutputTokens":17239,"totalTokens":8303882},"surface":"hermes-gateway","_meta":{"apiCalls":32,"hermesEstimatedCostUSD":0.008,"costSource":"provider_models_api"}}
Provider key is always the fixed string "nous"; model values are exactly the IDs served by Nous's inference API (GET /v1/models), so a models.dev nous entry can mirror them 1:1. Happy to run any parser/fan-out coverage you land against the real ledger and report back.
Fixed on main via #4015 and shipping in 0.67.1. Explicitly Nous-billed rows from your extractor now reach the Nous Portal row in the opt-in OpenCodex Usage & Spend source: exact Nous/model pricing supplies estimates, missing rates stay unpriced, _meta amounts are ignored, and Portal credits remain separate. Your three sanitized samples are preserved unchanged as the fixture, and the regression fails on the old dispatcher and passes after the route. One optional follow-up on your side: emitting the standard conversationId would let multiple model rows group into one Hermes session; the current request-ID fallback works fine without it. Thanks @Reztahla for the producer source and samples!
Thanks @steipete — excellent turnaround, and the fixture-preserving regression test is much appreciated.
Follow-up executed: the extractor now emits the standard conversationId key (it had been emitting conversationID, which your parser correctly ignores — that's why the request-ID fallback was doing all the grouping). Ledger regenerated: all 23 entries carry conversationId, collapsing into 21 Hermes sessions, including two dual-model sessions (e.g. z-ai/glm-5.3-flash + anthropic/claude-* in one conversation) that will now group into a single row per session. Gist updated accordingly.
For anyone landing here: entries will appear in the Nous Portal spend row under Settings → Usage & Spend with the "OpenCodex usage logs" toggle enabled, starting with v0.67.1 — usageStatus: "estimated" list-price figures priced by CodexBar's catalog (unpriced models stay token-mix-only), with Portal credit balances remaining on the separate Nous quota card.
Closing this out from my side — thanks again for the fast, precise handling.