Skip to content

Cache system prompt for claude #584

Closed

Description

@hadley

Might be useful compromise between doing nothing and figuring out how to fully implement.

Activity

  1. alvarojpf commented on Jul 22, 2025

    @alvarojpf

    I believe this feature is important for production environments and would be a valuable addition.

  2. kbenoit commented on Jul 22, 2025

    @kbenoit
    Contributor

    This would be a great addition, especially it it could work for the parallel_chat_* functions, which I typically call on a vector of input texts all being processed by the same prompt, often a very long prompt.

  3. added this to the v0.4.0 milestone on Oct 9, 2025
  4. hadley commented on Oct 27, 2025

    @hadley
    MemberAuthor

    Docs at https://docs.claude.com/en/docs/build-with-claude/prompt-caching — need to add "cache_control": {"type": "ephemeral"} to appropriate blocks. Probably also want to cache tools. I think this looks straightforward to implement. Also need to double check that cached values are read. Need to caveat that we don't track cache writes so that cost is lost.

  5. hadley commented on Oct 27, 2025

    @hadley
    MemberAuthor

    Actually based on https://docs.claude.com/en/docs/build-with-claude/prompt-caching#how-automatic-prefix-checking-works, looks like I can just turn it on for all conversations and it will always save you money if there's an additional turn. So just need an enum like cache = c("5min", "off").

  6. added a commit that references this issue on Oct 28, 2025
    d110ea9
  7. added a commit that references this issue on Nov 4, 2025
    5e0e2ea
  8. 1beb commented on Mar 14, 2026

    @1beb

    Noting that this doesn't work for AWS Bedrock. I'm going to submit a PR.

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions