Skip to content

perf(roadmap): a stage return reads the Claude prompt cache #7922

Done

Description

@dan-petty

Problem

On a Claude gateway group, each gate return of a stage plan writes the whole request into the prompt cache again.

bound_previous sends the request with previous and problem as one user message. Anthropic reuses a cached prefix only up to a cache break. The only breaks are the system message and the last message, so the changed user message misses the cache after the tools and the system text.

Evidence

A plan-only stage run of #5041 on claude-sonnet-5-5 on 2026-11-30 made 9 plan runs. The first call of each of the 8 returns read 17,268 tokens from the cache and wrote about 52,300. These 8 writes cost about 1.07 USD of the 1.97 USD of the run. A call that read the cache cost 0.01 to 0.06 USD.

DeepSeek reuses any token prefix, so its returns hit the cache.

Change

  • Send the plan request as two text parts with a cache break between them: the part that each return repeats, and the rest. The joined text stays the same, so the model reads the same request.
  • The model of a Claude group turns the cache break into cache_control through the documented hook of pydantic-ai. Other models drop the break.

Done when

A live second request that differs only after the break reads the repeated part from the cache.

Alternatives check of 2026-11-30: not-applicable.
Class: perf, no model call.
Tool: none found.

Activity

  1. added
    type/infra
    source/agent
    scope/roadmap
    status/new
    on Nov 30, 2026
  2. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor
  3. added
    effort/low
    value/high
    priority/p2-medium
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 30, 2026
  4. removed
    status/in-review
    on Nov 30, 2026
  5. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-30 22:54 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/infravalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions