Skip to content

Propagate cache key and service tiers in compact#21249

Merged
aibrahim-oai merged 15 commits intomainfrom
aibrahim/compact-cache-tier
May 6, 2026
Merged

Propagate cache key and service tiers in compact#21249
aibrahim-oai merged 15 commits intomainfrom
aibrahim/compact-cache-tier

Conversation

@aibrahim-oai
Copy link
Copy Markdown
Collaborator

@aibrahim-oai aibrahim-oai commented May 5, 2026

Why

/responses/compact should preserve the request-affinity fields that apply to the active auth mode. ChatGPT-auth compact requests need the effective service_tier, and compact requests for every auth mode need the stable prompt_cache_key, so compaction does not quietly lose routing or cache behavior that normal sampling already has.

This follows the request-parity direction from #20719, but keeps the net change focused on the compact payload fields needed here.

What changed

  • Add service_tier and prompt_cache_key to the compact endpoint input payload.
  • Build the remote compact payload from the existing responses request builder output so Fast still maps to priority when compact sends a service tier.
  • Pass the turn service tier into remote compaction, but only include it in compact payloads for ChatGPT-backed auth.
  • Keep prompt_cache_key on compact payloads for all auth modes.
  • Add request-body diff snapshot coverage in core/tests/suite/compact_remote.rs for:
    • API-key auth reusing prompt_cache_key while omitting service_tier even when Fast is configured.
    • ChatGPT auth reusing both service_tier and prompt_cache_key.
  • Drive the snapshot coverage through five varied turns: plain text, multi-part text, tool-call continuation, image+text input, local-shell continuation, and final-turn reasoning output.

Verification

  • Added insta snapshots for compact request-body parity against the last normal /responses request after five varied turns.
  • Not run locally per repo guidance; relying on GitHub CI for test execution.

Add service_tier and prompt_cache_key to the compact endpoint input by reusing the responses request builder output for remote compaction. Add request-body diff snapshot coverage for API-key and ChatGPT auth so prompt cache key parity and ChatGPT service tier propagation stay pinned.

Co-authored-by: Codex <[email protected]>
@aibrahim-oai aibrahim-oai requested a review from a team as a code owner May 5, 2026 21:41
aibrahim-oai and others added 2 commits May 6, 2026 00:46
Drive the compact request parity coverage through five varied turns, including multi-part text, tool output, image input, local shell output, and final-turn reasoning. Update the request-body diff snapshots so prompt_cache_key and ChatGPT service_tier parity are checked after a realistic history shape.

Co-authored-by: Codex <[email protected]>
Only propagate service_tier into /responses/compact when the active auth is ChatGPT-backed. Keep prompt_cache_key on compact requests for all auth modes, and update the API-key parity snapshot to prove service_tier is omitted even when the session has Fast configured.

Co-authored-by: Codex <[email protected]>
@aibrahim-oai aibrahim-oai changed the title Propagate compact cache request fields Propagate compact cache id and service tiers May 5, 2026
@aibrahim-oai aibrahim-oai changed the title Propagate compact cache id and service tiers Propagate cache key and service tiers May 5, 2026
@aibrahim-oai aibrahim-oai changed the title Propagate cache key and service tiers Propagate cache key and service tiers in compact May 5, 2026
aibrahim-oai and others added 8 commits May 6, 2026 00:58
Group compact request controls behind a named settings value so the compact client call stays below the argument-count lint while preserving the ChatGPT-only service tier gate.

Co-authored-by: Codex <[email protected]>
Narrow the compact request helper to crate visibility and remove duplicate TUI fixture fields introduced by the main merge.

Co-authored-by: Codex <[email protected]>
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but the test harness look super heavy and not sure of the value it brings

Comment thread codex-rs/core/src/client.rs Outdated
ContextSnapshotRenderMode::FullText => {
normalize_snapshot_uuids(&normalize_snapshot_line_endings(text))
}
ContextSnapshotRenderMode::KindOnly => unreachable!(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel those are usually not good practice as they don't contain a lot of debug info. But ok for tests I guess

Comment thread codex-rs/core/tests/common/context_snapshot.rs Outdated
Comment thread codex-rs/core/tests/common/context_snapshot.rs Outdated
@aibrahim-oai aibrahim-oai merged commit 5d6f23a into main May 6, 2026
26 checks passed
@aibrahim-oai aibrahim-oai deleted the aibrahim/compact-cache-tier branch May 6, 2026 10:38
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants