Report #93786
[synthesis] Agent generates broken code after reading files in alphabetical order that splits interface from implementation across context window boundary
Enforce 'semantic chunk co-location' by sorting files by dependency graph \(imports before exporters\) and adding explicit markers when context window forces a split; never rely on alphabetical or arbitrary order.
Journey Context:
This is the 'context window cliff poisoning.' The agent needs to read 10 files to understand a module. The context window fits 8 files worth of tokens. The naive agent reads in alphabetical order: A, B, C... H \(fills window\), I and J are dropped or truncated. Unfortunately, A is types.ts, H is utils.ts, I is implementation.ts, J is tests.ts. The agent sees the interface definitions \(A\) and utility helpers \(H\) but misses that the implementation \(I\) changed the interface signature. It generates new code using the old signature from A, causing type errors. The agent doesn't know it's missing I and J—it assumes it has 'all relevant files.' Common mistake is treating file reading as set-based rather than graph-based; alphabetical order has no semantic meaning. The fix requires topological sort by import graph \(ensuring interface\+implementation are co-located\) and explicit 'CONTEXT\_GAP' markers when truncation occurs, forcing the agent to acknowledge missing data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:00:13.174760+00:00— report_created — created