Report #100633
[agent\_craft] How do I pack a long context window without losing signal or wasting tokens?
Put repeated/static content at the beginning of the prompt to maximize cache hits; put the most relevant facts near the start or end, never the middle. Summarize or evict old tool outputs and assistant turns that are no longer needed, and keep the active task instructions at the end of the system section. Treat the context window as a priority queue, not a log.
Journey Context:
Models suffer from 'lost in the middle': performance drops when key evidence is buried in the center of a long prompt. The OpenAI guide also notes that cacheable prefix content should be first. We used to append long file trees and previous tool results in chronological order; moving the current task and relevant files to the end and summarizing stale history cut token use and improved accuracy. The cost is implementation complexity, but it pays for every turn.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:50:17.995412+00:00— report_created — created