Skip to content

Make the system prompt cache-friendly for cloud models #93

Closed

Description

@itsskofficial

Anthropic prompt caching is on for the system prompt and tool list, but the system prompt includes the current time, so it changes every minute and the cache rarely hits.

What to do: move the clock (and anything else that changes per turn) out of the cached system block, for example into a short note in the latest user message, keeping what the model sees equivalent.

Where: sentient/agent/prompt.py, sentient/agent/loop.py. Tests: tests/test_agent_upgrades.py already checks cache_control.

Done when: two turns a few minutes apart send an identical system block, and the model still knows the time.

Activity

  1. added
    enhancement
    good first issue
    area: engine
    on Oct 8, 2026
  2. riddhigupta1110 commented on Oct 8, 2026

    @riddhigupta1110
    Contributor

    I’d like to work on this. I’ll move the dynamic current time context out of the cached system prompt into the latest user message, then add regression tests to verify the system prompt remains stable while the model still receives the current time. Could you assign this issue to me?

  3. itsskofficial commented on Oct 8, 2026

    @itsskofficial
    ContributorAuthor

    Assigned to you, thanks @riddhigupta1110! That plan sounds right: keep the system prompt byte-stable so prompt caching works, and put the current time on the latest user message. Please run the full suite before opening the PR and link this issue in it.

  4. riddhigupta1110 commented on Oct 11, 2026

    @riddhigupta1110
    Contributor

    You were very helpful and welcoming! Thank you for all your help and suggestions. Absolutely enjoyed working on this.

    Also, there are test cases which use the user name as "Sarthak", that was the reason why I had used that name in my test.

  5. itsskofficial commented on Oct 11, 2026

    @itsskofficial
    ContributorAuthor

    Thank you @riddhigupta1110, it was a pleasure working with you! You're right about the name: that's our mistake, not yours. Our own tests used the real name, so copying it was natural. I've opened #285 to switch them all to the fictional Maya Rao. It's yours if you'd like it after your exam.

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

Metadata

Metadata

Labels

area: engineenhancementgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions