Report #4971
[agent\_craft] Chain-of-thought reasoning degrades or disappears when placed in the middle of long file contexts
Place the explicit chain-of-thought trigger \(e.g., 'Let's think step by step' or structured tags\) AFTER the relevant code snippets but BEFORE the final answer generation, never buried in the middle of retrieved context chunks.
Journey Context:
Research on 'Lost in the Middle' \(arXiv:2307.03172\) shows LLMs ignore information in the middle of long contexts. Agents often retrieve 10\+ code files and stuff them into the prompt with a 'think step by step' at the very end—by then the model has already processed the critical code. CoT must be positioned to attend to the immediately preceding context. Alternatives like putting CoT at the very start cause the model to reason about the query before seeing the code. Structured XML like helps but placement matters more than format.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:22:47.541653+00:00— report_created — created