You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bfd28e0
Browse filesBrowse the repository at this point in the historyBrowse files
fix(codex): date fallback review model pricing (#1303)
* fix(codex): date fallback review model pricing
Codex can emit the internal codex-auto-review label for review runs, but pricing that label as gpt-5.5 for every historical row overstates older usage.
Resolve that label while parsing Codex logs, using a small release-date table from models.dev so each event falls back to the newest known Codex/OpenAI model available on the log date without extra I/O in the hot path.
Remove the undated pricing alias for codex-auto-review, keep the raw alias handling for gpt-5.3-spark, and document the date-aware fallback behavior in the Codex guide.
* fix(codex): clarify review fallback edge cases
Address review feedback on the date-aware codex-auto-review fallback.
Malformed timestamps now use the same conservative gpt-5 fallback as dates before the known release table, avoiding accidental newest-model pricing for bad data.
The Codex guide now states that the parser maps codex-auto-review before pricing, and the fallback table documents its descending date-order invariant.
* fix(codex): validate review fallback dates
Resolve codex-auto-review model fallback dates from the raw log timestamp used for model selection instead of only the normalized event timestamp. This prevents malformed timestamp strings from being discarded and replaced by file mtime before the fallback decision.
Validate YYYY-MM-DD components before comparing release dates, including month ranges, month lengths, and leap years. Invalid or missing dates now conservatively resolve to gpt-5.
Add regression coverage for invalid month and non-leap-day Codex review logs.
* fix(codex): generate review fallback models
Replace the hand-written codex-auto-review release table in the parser with an embedded snapshot generated from the pinned models.dev input.
Extend the models.dev snapshot generator to emit Codex auto-review fallback metadata alongside the existing pricing snapshot, and wire the just recipe to refresh both generated files.
Keep runtime lookup fast by parsing the tiny embedded snapshot once through LazyLock, while preserving the existing date-aware fallback behavior and malformed-date conservative fallback.
* fix(nix): include codex auto-review fallbacks in build source
The Nix cleanSource filter only whitelists specific JSON files alongside
Cargo sources. The newly added codex-auto-review-fallbacks.json embedded
via include_str! by the codex parser was being filtered out, causing the
Linux/macOS/Windows native package builds to fail with 'No such file or
directory' at compile time.
Co-authored-by: Codesmith <[email protected]>
* fix(justfile): short-circuit snapshot copy on failure
Replace ';' with '&&' between the nix build and two cp commands in the
gen-models-dev-pricing recipe so that a failed earlier step doesn't get
silently masked by a later successful cp.
Co-authored-by: Codesmith <[email protected]>
* fix(codex): try alternate timestamp fields when top-level timestamp is malformed
The model-date resolution chain in codex_model_timestamp_from_result used
raw_or_normalized_codex_timestamp, which returned any non-empty string as-is
regardless of whether it parsed as a date. That short-circuited the or_else
chain, so a malformed top-level `timestamp` would prevent the parser from
looking at `created_at`, `created_at_camel`, nested result-field
timestamps, or the file mtime fallback, and forced events through the
conservative gpt-5 mapping.
Validate the raw string against codex_timestamp_date before short-circuiting;
fall through to normalize_codex_timestamp / normalize_value_timestamp and
finally None so the rest of the chain can supply a valid date. Mirror the
same change for the serde_json::Value path.
Also fix the models.dev fallback generator so a gpt-5.x decimal base model is
only dropped when a gpt-5.x-codex variant exists on the SAME release date.
When the codex variant ships later, keeping the base entry lets events in the
gap still resolve to the most recent model actually available then.
Co-authored-by: Codesmith <[email protected]>
---------
Co-authored-by: Codesmith <[email protected]>
Copy file name to clipboardExpand all lines: docs/guide/codex/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ These views support `--json`, `--compact`, `--offline`, and `--speed auto|standa
47
47
48
48
-**Token deltas** – Each `event_msg` with `payload.type === "token_count"` reports cumulative totals. The CLI subtracts the previous totals to recover per-turn token usage (input, cached input, output, reasoning, total).
49
49
-**Per-model grouping** – The `turn_context` metadata specifies the active model. We aggregate tokens per day/month and per model. Sessions lacking model metadata (seen in early September 2025 builds) are skipped.
50
-
-**Pricing** – Rates come from LiteLLM's pricing dataset via the shared `LiteLLMPricingFetcher`. Model aliases such as `gpt-5.5` are resolved through the pricing cache when available.
50
+
-**Pricing** – Rates come from LiteLLM's pricing dataset via the shared `LiteLLMPricingFetcher`. Codex's internal review label is resolved to the newest known model for the log date before pricing is calculated.
51
51
-**Speed pricing** – `--speed auto` is the default. It reads `config.toml` from each `CODEX_HOME` root and applies fast pricing when any Codex config has `service_tier = "priority"` or legacy `service_tier = "fast"` configured. Fast mode uses the model-specific LiteLLM multiplier when available and otherwise falls back to 2x pricing. Pass `--speed fast` or `--speed standard` to override config-based detection.
52
52
-**Legacy fallback** – Early September 2025 logs that never recorded `turn_context` metadata are still included; the CLI assumes `gpt-5` for pricing so you can review the tokens even though the model tag is missing (the JSON output also marks these rows with `"isFallback": true`).
53
53
-**Cost formula** – Non-cached input uses the standard input price; cached input uses the cache-read price (falling back to the input price when missing); and output tokens are billed at the output price. All prices are per million tokens. Reasoning tokens may be shown for reference, but they are part of the output charge and are not billed separately.
@@ -60,7 +60,7 @@ These views support `--json`, `--compact`, `--offline`, and `--speed auto|standa
60
60
|`CODEX_HOME`| Override the root directory, or comma-separated directories, containing Codex homes or saved `codex exec --json` JSONL files |
When Codex emits a model alias (for example `gpt-5.5`), the CLI automatically resolves it through the LiteLLM pricing data when possible. No manual override is needed.
63
+
When Codex emits a model alias, the CLI automatically resolves it through the LiteLLM pricing data when possible. For `codex-auto-review`, the Codex parser maps the label to the newest known Codex/OpenAI model available on the log date using a pinned models.dev snapshot before pricing uses the resolved model name. No manual override is needed.
0 commit comments