GPT-5.6 cache_write_tokens are dropped from TokenUsage and rollout JSONL

Open 💬 0 comments Opened Jul 11, 2026 by chusia06

What version of Codex CLI is running?

codex-cli 0.144.1

What subscription do you have?

Not relevant to this source-level parsing issue.

Which model were you using?

gpt-5.6-sol

What platform is your computer?

Platform independent; confirmed in the current source.

What terminal emulator and version are you using?

Not applicable. This is a usage parsing and telemetry issue rather than a terminal-specific issue.

What issue are you seeing?

GPT-5.6 Responses report cache writes in
usage.input_tokens_details.cache_write_tokens, but Codex currently drops
this field while parsing usage.

The current SSE response parser only declares cached_tokens:

https://github.com/openai/codex/blob/385c0a9351e2199929e01f7864ec78a8f7d5e580/codex-rs/codex-api/src/sse/responses.rs#L122-L152

The downstream TokenUsage structure also has no cache-write field:

https://github.com/openai/codex/blob/385c0a9351e2199929e01f7864ec78a8f7d5e580/codex-rs/protocol/src/protocol.rs#L2025-L2037

Because unknown Serde fields are ignored, cache_write_tokens is discarded
before TokenCount events, app-server/SDK usage events, and rollout/session
JSONL are produced.

This creates an observability gap for GPT-5.6. Cache reads can be measured
through cached_input_tokens, but cache writes cannot be measured even though
GPT-5.6 cache writes are billed at 1.25x the uncached input-token rate.

This report concerns usage telemetry only. Server-side billing may still be
correct.

What steps can reproduce the bug?

  1. Run Codex with gpt-5.6-sol.
  2. Generate requests eligible for prompt caching.
  3. Inspect token_count events in the resulting rollout/session JSONL.
  4. Observe that usage includes:
  • input_tokens
  • cached_input_tokens
  • output_tokens
  • reasoning_output_tokens
  • total_tokens
  1. Observe that cache_write_tokens is never represented.
  2. Inspect the SSE parser and TokenUsage definitions linked above; neither

structure has a field capable of preserving the API value.

OpenAI documents cache_write_tokens here:

https://developers.openai.com/api/docs/guides/prompt-caching

What is the expected behavior?

Codex should preserve cache-write usage as an optional, backward-compatible
field through the complete usage path:

  • ResponseCompletedInputTokensDetails.cache_write_tokens
  • TokenUsage.cache_write_tokens
  • total/last-token usage aggregation
  • TokenCount events
  • app-server and SDK usage events
  • rollout/session JSONL

Tests should cover deserialization, accumulation, serialization, and compatibility
with responses or old rollout records that do not contain the field.

Additional information

A related observability concern was previously raised in a comment on the
forked-subagent cache-lineage issue:

https://github.com/openai/codex/issues/24704#issuecomment-4937276202

A separate issue seems useful because cache-write telemetry affects all GPT-5.6
usage, independently of subagent fork behavior.

View original on GitHub ↗