-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Feature: configurable bootstrap file injection order for prompt cache optimization #65438
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
OpenClaw splits workspace bootstrap files into "stable" (before
OPENCLAW_CACHE_BOUNDARY) and "dynamic" (after) for Anthropic prompt cache optimization. Currently, onlyHEARTBEAT.mdis classified as dynamic (DYNAMIC_CONTEXT_FILE_BASENAMES), and the injection order is hardcoded inCONTEXT_FILE_ORDER.Operators who use additional workspace files (e.g.,
SESSION_HANDOFF.md,RECENT_SESSIONS.md,STATE.md) that change frequently have no way to:Proposal
Option A: Config-based dynamic file list
{ "agents": { "defaults": { "bootstrapDynamicFiles": ["SESSION_HANDOFF.md", "RECENT_SESSIONS.md"] } } }Files listed here would be added to
DYNAMIC_CONTEXT_FILE_BASENAMESat runtime, placing them after the cache boundary.Option B: Full injection order control
{ "agents": { "defaults": { "bootstrapFileOrder": [ "SOUL.md", "IDENTITY.md", "USER.md", "TOOLS.md", "AGENTS.md", "MEMORY.md", "BOOTSTRAP.md" ], "bootstrapDynamicFiles": ["HEARTBEAT.md", "SESSION_HANDOFF.md"] } } }Why this matters
With
cacheRetention: "long", the stable prefix of the system prompt gets cached at 90% discount on Anthropic. Frequently-changing files that land before the boundary invalidate the cache on every change, causing full-price re-reads of the entire prefix. For deployments with large bootstrap contexts (50K+ chars), this can mean $10-30/month in unnecessary cache invalidation costs.Current behavior (source refs)
CONTEXT_FILE_ORDER: hardcodedMapinsystem-prompt-*.js(AGENTS=10, SOUL=20, IDENTITY=30, USER=40, TOOLS=50, BOOTSTRAP=60, MEMORY=70)DYNAMIC_CONTEXT_FILE_BASENAMES: hardcodedSetcontaining onlyheartbeat.mdisDynamicContextFile(): checks membership in the above setCONTEXT_FILE_ORDERgetMAX_SAFE_INTEGERpriority (alphabetical tiebreak), placed before cache boundary as stableEnvironment
cacheRetention: "long"