Skip to content

[Bug][cache] Keepalive reads cache directives from tool arguments and schema examples #6227

Closed

Description

@Afloat16

Category and environment

Category A: prompt cache. Reproduced on master dc041dd (bili 0.1.213), Node 24.22.1 on Linux.

Reproduction

Send an Anthropic request with a normal five-minute system cache breakpoint and a tool_use input containing ordinary JSON data such as cache_control: {type: "ephemeral", ttl: "1h"}. The recursive keepalive detector treats that input value as a directive. It chooses one hour and schedules at 3,240 seconds rather than 270 seconds, allowing the real five-minute cache to expire.

A matching value inside input_schema examples also arms keepalive when the request has no real cache breakpoint at all.

Expected correction

Read only supported request and block breakpoint locations: top-level automatic cache_control, tool definitions, system blocks and message content blocks. Treat nested input/schema JSON as data. Preserve one-hour precedence among real breakpoints and implicit five-minute defaults.

Evidence and scope

Four regressions fail and one control passes on unchanged master. All five pass with the fix, including production noteSuccessfulForward with a deterministic scheduler; all 36 existing keepalive tests also pass (41 total). Typecheck passed.

The supported locations follow https://platform.claude.com/docs/en/build-with-claude/prompt-caching . This change only inspects data; it does not rewrite tool inputs or signed content.

History: #5669 fixes omitted TTL defaults; #6078 handles stale asynchronous ping completion after rearming. Neither limits the recursive detector to real breakpoint locations. Open/closed searches for detectKeepaliveTier, tool cache_control and keepalive schema found no matching correction.

Suggested labels: bug, p2, scope/wiring.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions