fix: cache-friendly system prompt order; drop blog-ideas from prompt #42
No reviewers
Labels
No labels
Agent
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
joshtronic/igor!42
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/cache-friendly-prompt-order"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Touchdown Labs piece on KV cache memory hierarchy got me thinking
about what we control on the prompt side. Two changes that should
reduce "pay for turn 1 again" tax across consecutive ticks:
(a) Reorder system prompt for cache stability.
Prompt caching keys on shared PREFIX. If volatile content sits
upstream of stable content, every change to the volatile bit
invalidates the cache for everything downstream too. Previous
order put AGENTS.md LAST -- so any MEMORY.md or blog-ideas.md
change invalidated AGENTS.md too.
New order, most-stable-first:
AGENTS.md -- PR-only changes
identity.md -- PR-only changes
index.md -- PR-only changes
memories/MEMORY.md -- Claude edits occasionally
That gives us a stable upstream prefix that survives MEMORY.md
edits, and a stable AGENTS.md + identity prefix that survives
even MEMORY.md churn.
(b) Drop blog-ideas.md from the system prompt entirely.
blog-ideas.md is the highest-churn file in brain -- Claude
appends ideas regularly during reading and journaling ticks.
Loading it in-prompt guaranteed cache invalidation on every
write. AGENTS.md updated to say it's Read-on-demand instead --
Claude opens it via the Read tool when shipping a post or
considering one, and Edits it to append new ideas (harness
picks up the edit alongside the journal commit).
Also collapsed the four redundant identity.md/index.md fallback
conditionals -- brain_system_prompt now handles missing files
gracefully (skips them, always includes AGENTS.md), so the
guard is just a single warning log if the required brain files
are missing.
What this does NOT do: longer cache TTL (still 5min default).
Verifying that gap requires checking Anthropic Console for
cache_creation vs cache_read token counts on consecutive ticks
~10-15 min apart. If the cache is dying between ticks, 1h TTL
would help -- but Claude Code doesn't expose the flag, would
require dropping the CLI and hitting /v1/messages directly.
Worth measuring before deciding.