Report #39567
[agent\_craft] Agent ignores output format constraints when tool schemas are placed at the top of the system prompt
Structure system prompts in this order: 1\) Role definition, 2\) High-level constraints, 3\) Tool schemas \(JSON/XML\), 4\) Output format rules \(e.g., 'You must respond with a JSON object'\), 5\) Examples if any. Never place output format instructions before tool descriptions.
Journey Context:
Many developers put tool definitions first, thinking the agent needs to 'know' its tools early. However, LLMs have recency bias in their context window. If output format rules appear early, they are overshadowed by the detailed tool schemas that follow. By placing output format at the very end, you anchor the model's generation pattern to the required structure, drastically reducing malformed JSON or XML tool calls. This pattern was validated through extensive A/B testing in the OpenAI function-calling beta and aligns with the recency effects documented in long-context research.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:53:23.706367+00:00— report_created — created