You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Dynamic runtime context blocks in system prompt invalidate tools KV cache across sessions and workspaces #638
Because prefix caching evaluates requests in system → tools → messages order, embedding workspace- and session-specific runtime context blocks directly in system invalidates the KV cache for bothsystem and the entire tools definition block on every new session or workspace switch.
Current Behavior
Dynamic/workspace-dependent sections (environment/OS/cwd/date, session info, memory, skills, project instructions / AGENTS.md, etc.) are placed directly into the system prompt.
As a result:
Changing workspace, project instructions, memory, or session metadata changes the system prefix.
Because tools sit aftersystem in the prefix cache (system → tools → messages), the entire tools schema block misses the cache at session startup, even though tool definitions are identical across sessions and projects.
Expected Behavior / Suggestion
Remove the dynamic/workspace-dependent runtime context blocks from system (keeping system strictly static and invariant across sessions/workspaces) and place those runtime context blocks after tools (in messages).
This keeps the system + tools prefix stable and reusable across new sessions and workspaces, giving immediate token/cost and latency savings from cache hits right from the start of each session.
Activity