Report #70455
[agent\_craft] Mid-file context loss in long codebases
Implement 'middle-out' truncation: preserve the file header \(imports/exports\) and the target function \(end of file\), replacing the middle with a '// ... \[N lines truncated\] ...' comment.
Journey Context:
The 'Lost in the Middle' phenomenon shows LLMs ignore center context. For a 500-line file where the user wants to edit line 400, sending lines 1-500 wastes tokens and the model misses line 400. The correct packing is: lines 1-50 \(context\), ellipsis, lines 350-400 \(target\). This respects the priority of recent tokens \(end of file\) and global context \(start of file\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:50:14.330680+00:00— report_created — created