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
Currently, codewhale injects project-level instructions (AGENTS.md, .codewhale/constitution.json) once, at session start. These remain in the prefix cache throughout the session. However, long multi-turn sessions accumulate context — after a few dozen tool calls and sub-agent results, the early instructions drift far from the model's attention window. The model still "has" them in context, but doesn't actively reference them when making decisions at turn 80.
This creates a documented failure mode in my project: the model makes claims in turn 80 that violate rules it read and discussed at turn 5. I've captured this as a pattern in my XXX.md — "the rules are in context, but behavior doesn't follow them." Adding the rules to context again mid-session would invalidate the prefix cache — too expensive. I need a lighter mechanism.
Proposed solution
A config option (e.g., [instructions].inject_every_turn = true or a turn_preface field) that appends a short, stable set of instructions to every new user turn in the session. This "turn preface" would be:
Short — 3-8 lines max, not full documents. A checklist or behavioral trigger, not reference material.
Stable — same text every turn, so it forms its own prefix cache segment at the end of the turn.
Optional — off by default, per-project or per-user configurable.
Example use case:
[turn_preface]
text = """
Before acting, scan the constitution, verification_policy, and XXX_pattern_index.
For any negative claim (can't do, missing, broken), grep source code first — never infer from docs alone.
"""
This would appear right before or after the user's message in each turn, as a short injected block that requires no user action (no /skill self-check every turn).
Why not just use Skills or Memory?
Skills require user invocation every time (/skill self-check). This works for single-shot checks, but not for sustained behavioral discipline across dozens of turns.
Memory is AI-managed recall, not deterministic instruction injection.
Why not just make the instruction longer?
The instructions are already in the system prompt. The problem isn't missing information — it's a behavioral gap between "having rules in context" and "applying rules at decision time." A per-turn short trigger serves as a cognitive nudge, not a content delivery mechanism.
Impact on prefix cache
A short, stable turn_preface appended at the same position every turn would quickly become part of the prefix cache tail, minimizing cost. It's the injection equivalent of the turn_meta block that already exists.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, codewhale injects project-level instructions (AGENTS.md, .codewhale/constitution.json) once, at session start. These remain in the prefix cache throughout the session. However, long multi-turn sessions accumulate context — after a few dozen tool calls and sub-agent results, the early instructions drift far from the model's attention window. The model still "has" them in context, but doesn't actively reference them when making decisions at turn 80.
This creates a documented failure mode in my project: the model makes claims in turn 80 that violate rules it read and discussed at turn 5. I've captured this as a pattern in my XXX.md — "the rules are in context, but behavior doesn't follow them." Adding the rules to context again mid-session would invalidate the prefix cache — too expensive. I need a lighter mechanism.
Proposed solution
A config option (e.g., [instructions].inject_every_turn = true or a turn_preface field) that appends a short, stable set of instructions to every new user turn in the session. This "turn preface" would be:
Example use case:
[turn_preface]
text = """
Before acting, scan the constitution, verification_policy, and XXX_pattern_index.
For any negative claim (can't do, missing, broken), grep source code first — never infer from docs alone.
"""
This would appear right before or after the user's message in each turn, as a short injected block that requires no user action (no /skill self-check every turn).
Why not just use Skills or Memory?
Why not just make the instruction longer?
The instructions are already in the system prompt. The problem isn't missing information — it's a behavioral gap between "having rules in context" and "applying rules at decision time." A per-turn short trigger serves as a cognitive nudge, not a content delivery mechanism.
Impact on prefix cache
A short, stable turn_preface appended at the same position every turn would quickly become part of the prefix cache tail, minimizing cost. It's the injection equivalent of the turn_meta block that already exists.
────────────────────────────────────────────────────────────
Let me know if this feature or a workaround already exists. Happy to provide code examples or test.
Beta Was this translation helpful? Give feedback.
All reactions