codex icon indicating copy to clipboard operation
codex copied to clipboard

GPT-6.2 Sol: implicit cache boundary excludes the previous assistant output, unlike GPT-6.1 Sol

Open Astricaelus opened this issue 2 weeks ago • 1 comments

Summary

With Codex CLI 0.169.1 and a Responses-compatible endpoint, GPT-6.2 Sol shows a consistent prompt-cache gap that tracks the previous response output tokens. GPT-6.1 Sol, with the same append-only tool-loop shape, reuses essentially the full previous request.

For adjacent requests in one thread:

GPT-6.1 Sol:
  current.cached_input_tokens ~= previous.input_tokens + previous.output_tokens

GPT-6.2 Sol:
  current.cached_input_tokens ~= previous.input_tokens
  gap = previous.input_tokens + previous.output_tokens - current.cached_input_tokens
      ~= previous.output_tokens + ~200

There is no compaction, retry, model switch, or reasoning-effort change in the measured pairs, and prompt_cache_key is stable.

Environment

  • Codex CLI 0.169.1
  • Models: gpt-6.2-sol and gpt-6.1-sol
  • Responses-compatible custom provider, wire_api = responses
  • store: false, streaming Responses, Responses Lite catalog entries
  • Values from token_usage_record.payload.usage in the session rollout JSONL

The 6.1 measurements span Codex 0.164.0 through 0.167.2; 6.2 measurements are from 0.169.1. This is not a perfectly matched client-version A/B, but both models use the same cache-relevant catalog fields and the client relies on implicit breakpoints in both builds.

Measured pairs

Model Prev input Prev output Prev total Current cached Gap
6.1 35,212 1,190 36,402 36,224 178
6.1 43,364 4,543 47,907 47,744 163
6.1 62,780 677 63,457 63,296 161
6.2 62,780 677 63,457 62,592 865
6.2 30,569 324 30,893 30,336 557
6.2 31,577 92 31,669 31,360 309

The 6.1 gap stays near the 128-token reporting boundary regardless of the previous output size. The 6.2 gap grows with the previous output size.

Last item in previous request 6.1 median gap 6.2 median gap
custom_tool_call ~180 tokens ~872 tokens
function_call ~177 tokens ~1,142 tokens
assistant message ~176 tokens ~532 tokens

The 6.1 medians cover thousands of pairs; the 6.2 sample is smaller but consistent across threads. The same turn ending still produces a much larger gap on 6.2.

Likely mechanism

The prompt-caching guide says that for GPT-5.6 and later the implicit breakpoint is placed at the end of the latest eligible message. Eligible messages are user messages, the last tool response in a consecutive group of tool responses, and the last developer message in the initial developer block. Assistant output items are not eligible implicit breakpoints.

Codex sends the full conversation in input and currently relies on that implicit breakpoint. ResponsesApiRequest carries prompt_cache_key and an optional prompt_cache_options with ttl, but it has no prompt_cache_options.mode and no prompt_cache_breakpoint field. There is no explicit breakpoint anywhere in the request path.

When a turn ends with custom_tool_call or function_call, the previous assistant output is after the latest eligible message. The next request can only reuse the prefix ending at that message, so the previous output is missing from the cached prefix. GPT-6.1 appears to include the assistant output in its effective boundary, which is why its gap is only the reporting boundary remainder.

GPT-6.2 also drops reasoning items after mid-conversation prefix edits or model changes. That can add to the loss and cause occasional hard resets, but it does not explain the consistent one-output-behind gap.

Expected behavior

Either Codex should emit an explicit cache breakpoint at the end of the reusable prefix for GPT-6.2 and later, or the request layout should end on an eligible boundary before the next request is sent. The public API supports prompt_cache_options.mode = explicit plus prompt_cache_breakpoint on supported content blocks; Codex cannot currently express either.

If explicit breakpoints cannot cover tool-call items, it would help to document that limitation and clarify whether the GPT-6.2 one-output-behind behavior is intentional. A stateful previous_response_id path may be an alternative, but that is a larger integration change.

Minimal reproduction

  1. Run Codex CLI 0.169.1 with gpt-6.2-sol and any Responses-compatible provider that reports cached_tokens.
  2. Execute an ordinary tool loop: a user request, one or more tool calls, and the follow-up model turns.
  3. Export the session rollout JSONL and compare adjacent token_usage_record entries:
prev_total = prev.input_tokens + prev.output_tokens
gap = prev_total - current.cached_input_tokens
  1. Repeat with gpt-6.1-sol using the same tool-loop shape.

Expected for 6.1: gap stays around 128-256 tokens.

Observed for 6.2: gap tracks previous.output_tokens and is often several hundred to several thousand tokens larger.

A matched 6.1/6.2 A/B on 0.169.1 would separate model behavior from version drift.

Related issues

  • #62109: GPT-6.2 Sol on Codex OAuth reports zero cached tokens for unchanged top-level instructions in a partially cached continuation. Different field-level symptom, same model family and cache-accounting area.
  • #51353: The Codex backend rejects prompt_cache_breakpoint for GPT-6.1 Sol.
  • #35300: Codex cannot emit prompt_cache_breakpoint, preventing reuse of stable startup prefixes.
  • #54091: Partial cache drops within GPT-6 Astra turns.

Request

Please confirm whether the GPT-6.2 assistant-output exclusion is expected. If it is not, the likely fix is to add explicit cache-breakpoint support to the Codex Responses request types and place a breakpoint at the end of the reusable prefix. If it is expected, documenting the 6.1 vs 6.2 difference and the available workarounds would prevent further low-hit-rate reports.

Astricaelus avatar Nov 18 '26 10:11 Astricaelus

+1

caokai674 avatar Nov 18 '26 10:11 caokai674