Skip to content

feat(explore): Add Prompt Cache tab that ranks cache misses and warming savings - #133205

Draft
sentry-junior[bot] wants to merge 2 commits into
masterfrom
feat/ai-prompt-cache-tab
Draft

sentry-junior[bot] wants to merge 2 commits into
masterfrom
feat/ai-prompt-cache-tab

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Why

LLM apps pay a cache-write premium every time the provider's prompt cache misses. A miss has one of two causes: the cache expired because calls were further apart than its lifetime (cache warming or a longer lifetime fixes that), or the prompt prefix changed (tools, system prompt or history, which only a code change fixes). Sentry can't show either today, and the savings in any one conversation are small, so the money only shows up when misses are ranked across an org by model, agent and call site. This PR shows that ranking in the product: a Prompt Cache tab that reads the API from #133195, so land that first.

What

Adds a Prompt Cache tab to Explore > Agents, next to Conversations, Traces and LLM Calls. It's hidden unless organizations:gen-ai-prompt-cache-insights is on. There's one row per model × agent × call site, ranked by estimated monthly waste:

  • Model, with the cache lifetime the estimate assumed (5 minutes for Anthropic, 30 minutes for OpenAI).
  • Agent (gen_ai.agent.name) and Call Site (code.file.path in code.function.name). Call Site shows "(not recorded)" until SDKs record code.* on gen_ai spans.
  • Rewrites: misses after the cache expired, plus prefix changes (a full rewrite while the cache was still warm).
  • Waste / mo, Warming / mo, Longer TTL / mo: monthly estimates, with the sampled amount underneath.
  • Conversations: the group's most wasteful conversations, linking to the conversation view.

The page's search bar and its project, environment and date filters apply to the analysis. A caption says how many conversations were sampled and how many calls were skipped because the provider's cache lifetime isn't reliable (Gemini). An alert shows when a conversation had more LLM calls than one request reads.

The screenshots use synthetic spans seeded into a local devserver.

Prompt Cache tab on Explore > Agents

Full page

A conversation link opens the conversation view

Part of

via @BYK.

--

View Session [Sentry]

Add a Prompt Cache tab next to Conversations, Traces and LLM Calls on
Explore > Agents, behind organizations:gen-ai-prompt-cache-insights. It
ranks model, agent and call site groups by estimated monthly prompt cache
waste, with what cache warming and a longer cache lifetime would save,
and links each group's worst conversations to the conversation view.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

decision-model-linter

api

static/app/views/explore/conversations/hooks/usePromptCache.tsx

  • warn returnsUnpaginatedList = INTRODUCED (0.82): List endpoints should paginate with self.paginate(...) and a cursor parameter. This change returns a list that can keep growing without paginating it. If the endpoint already existed, don't add pagination to it: that changes what existing callers get back.

decision-model-linter: 43 calls on 7 files, 115,776 input tokens, $0.0049, model typesafe/jev-1.13-20260917

The prompt cache endpoint now returns project IDs as strings.

This branch was successfully deployed

1 active deployment
Preview — b0138cad Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant