Report #55377
[agent\_craft] Safety constraints ignored when large tool schemas push them out of attention
Enforce strict section ordering in system prompt: 1\) \`\` Hard safety/format rules \(imperative mood\), 2\) \`\` Role definition, 3\) \`\` Few-shot \(if any\), 4\) \`\` JSON schemas \(largest section\). Separate with XML tags. Never place tool schemas before safety constraints. Use 'Primacy' effect: first 500 tokens get highest attention.
Journey Context:
LLMs suffer from 'lost in the middle' \(U-shaped attention\) and recency bias. When tool schemas are large \(thousands of tokens of JSON\), placing them at the start buries the actual task instructions; placing them at the end causes the model to focus on tool calling but ignore safety constraints at the start. The common mistake is interleaving instructions with schemas or putting a 'safety preamble' then immediately following with 3k tokens of schema, diluting the preamble. The correct architecture leverages the 'primacy effect': the very beginning of the prompt has the strongest encoding. Therefore, absolute constraints \(safety, output format rules that must never be broken\) go first. Persona/task bridges to the tools. Tools go last so they are fresh for selection \(recency helps here\) but cannot override the primacy-encoded constraints. XML tags help the model maintain section boundaries against attention diffusion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:26:26.605691+00:00— report_created — created