Skip to content

feat(api): expose managed-session usage and pricing - #1

Open
vlad-thenvoi wants to merge 3 commits into
lib-facade-v20.0.17from
feat/session-reasoning-api
Open

feat(api): expose managed-session usage and pricing#1
vlad-thenvoi wants to merge 3 commits into
lib-facade-v20.0.17from
feat/session-reasoning-api

Conversation

@vlad-thenvoi

@vlad-thenvoi vlad-thenvoi commented Jul 20, 2026

Copy link
Copy Markdown

What

Extends the all-provider embedding API in three narrowly scoped ways needed by Jam's managed-runtime usage importer and canonical pricing projection:

  • exposes optional provider reasoning_tokens on AgentSessionUsage, preserving None when the provider supplied no fact;
  • accepts additional Codex home directories and merges them with ordinary CODEX_HOME/default discovery;
  • quotes one caller-supplied canonical token vector from the build-pinned embedded pricing catalog without a file scan or network request.

The additional homes reuse ccusage's existing Codex parser, archived-session dedupe, date filtering, pricing, and session aggregation. Embedders do not need to mutate process-global environment variables or duplicate provider-file parsing. Pricing quotes include requested/resolved model, USD currency, a content-derived catalog version, and formula version. Unknown models explicitly return missing_pricing with no estimated amount rather than a misleading zero.

Why

Jam's Plan 74 runtime stores sandboxed Codex state under UUID-owned provider-state roots. Its canonical usage ledger must import those sessions while continuing to see ordinary host Codex sessions, preserving reasoning-token totals, and deriving a separately versioned cost projection from accepted raw facts.

Verification

  • cargo test --manifest-path rust/Cargo.toml -p ccusage --lib — 364 passed
  • cargo clippy --manifest-path rust/Cargo.toml -p ccusage --lib -- -D warnings
  • cargo fmt --manifest-path rust/Cargo.toml --all

Preserve provider-supplied reasoning/output-thinking totals on the all-provider session facade as an optional field. Missing metadata remains unknown rather than being coerced to zero, allowing Jam's canonical reconciliation importer to retain Codex token categories without parsing provider files itself.
Allow embedders to add managed Codex provider-state homes to the ordinary CODEX_HOME/default discovery set without mutating global environment variables. The all-provider pipeline reuses the existing Codex parser, archived-session dedupe, date filtering, pricing, and reasoning metadata.
@vlad-thenvoi vlad-thenvoi changed the title Expose provider reasoning totals in the session API feat(api): expose session reasoning and additional Codex homes Jul 20, 2026
Expose a scan-free, network-free pricing quote for one canonical token vector. Persistable quote metadata includes requested/resolved model, USD currency, a content-derived embedded catalog version, and formula version.

Unknown model pricing is explicit and returns no estimated cost, preventing downstream consumers from treating missing pricing as zero. Tests cover known and unknown model behavior; the full 364-test library suite and warnings-denied Clippy pass.
@vlad-thenvoi vlad-thenvoi changed the title feat(api): expose session reasoning and additional Codex homes feat(api): expose managed-session usage and pricing Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant