Report #35427
[agent\_craft] Agent ignores critical tool definitions or few-shot examples placed in the middle of long system prompts
Place mission-critical structural constraints \(tool JSON schemas, output format rules, and primary few-shot examples\) at the very beginning of the context window; place secondary constraints or negative examples at the very end. Never bury tool definitions in the middle of retrieved documentation or conversation history exceeding 4k tokens.
Journey Context:
LLMs exhibit a U-shaped attention curve known as 'Lost in the Middle'—performance degrades significantly when key information is positioned in the middle of long contexts. For agents, this means that if you inject 10 tool definitions after 5 turns of conversation, the model may hallucinate parameters for tool \#5. The common architectural error is chronological ordering: system prompt, then chat history, then 'by the way, here are your tools.' The fix is strict sandwiching: Tool schemas and format rules at TOP \(positions 0-500 tokens\), then dynamic context, then negative constraints/reminders at BOTTOM if the context exceeds 8k tokens. This maximizes the attention weights on the structural grammar constraints, preventing the model from drifting into free-form text when it should be emitting JSON tool calls.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:55:59.993650+00:00— report_created — created