Cache expiration countdown timer in status line

Open 💬 3 comments Opened Apr 21, 2026 by tom-huntington
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

CLI

What feature would you like to see?

I don't know what info the API returns, but it would be nice get some idea of how soon the cache is going to expire.

Perhaps you could estimate when it is going to expire, and display a countdown timer

Additional information

_No response_

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #18812
  • #17457
  • #17934

Powered by Codex Action

etraut-openai contributor · 4 months ago

That information isn't available to clients currently.

lucky-verma · 3 months ago

Adding implementation notes since PRs appear to be invitation-only and the exact server-side expiry is not exposed to clients.

A conservative client-side status-line item still seems useful and small in scope:

  • Add a configurable status-line item: cache-expiry.
  • Accept aliases: cache-timer, prompt-cache, prompt-cache-expiry.
  • Render Cache cold until a turn is plausibly prompt-cache eligible.
  • After a cache-eligible request, render Cache 5:00 and count down once per second.
  • Return to Cache cold after the local estimate expires.
  • Document that this is an estimate, not a server-authoritative expiry timestamp.

A local prototype against the TUI code touched these areas:

  • codex-rs/tui/src/bottom_pane/status_line_setup.rs: add StatusLineItem::PromptCacheExpiry, descriptions, aliases, preview mapping, and parser tests.
  • codex-rs/tui/src/bottom_pane/status_surface_preview.rs: add preview text like Cache 5:00.
  • codex-rs/tui/src/chatwidget.rs: store prompt_cache_warm_until: Option<Instant> and a prompt_cache_timer_tick_pending flag; refresh this from TokenUsageInfo after each turn.
  • codex-rs/tui/src/chatwidget/status_surfaces.rs: render Cache cold / Cache M:SS, schedule a one-second refresh tick while warm, and clear state when expired.
  • codex-rs/tui/src/app_event.rs + app/event_dispatch.rs: add a lightweight PromptCacheTimerTick event to refresh the status line.
  • codex-rs/tui/src/chatwidget/tests/status_and_layout.rs: cover cold state, non-eligible small prompts, initial Cache 5:00, countdown formatting, and expiry back to cold.

The prototype used a deliberately conservative threshold/duration:

const PROMPT_CACHE_ELIGIBLE_INPUT_TOKENS: i64 = 1024;
const PROMPT_CACHE_WARM_DURATION: Duration = Duration::from_secs(5 * 60);

The main product decision is whether Codex wants an estimated indicator when exact cache metadata is unavailable. If yes, the UI can label the item as estimated and avoid implying billing or server cache guarantees. If no, this issue probably needs server/API support for exact cache expiry metadata before it can be made precise.

<img width="1016" height="323" alt="Image" src="https://github.com/user-attachments/assets/df2bfaaf-e4ed-42e2-b0b4-1168ce572e94" />

<img width="850" height="250" alt="Image" src="https://github.com/user-attachments/assets/890cae25-55db-4b64-bbc7-49535bf2f95a" />