Long Context Coding: Real-World Limits and Pitfalls to Avoid

    An empirical look at what large context windows actually deliver for long-horizon coding tasks. This article examines why the advertised window size matters less than behavioral stability near the limit and seamless continuation after context compaction, what to expect in the 100K–200K token range, and why externalizing state into process files on disk is the practical fix for state loss, rule dilution, and failed handoffs. It also covers cross-model collaboration, version drift, and why the execution harness deserves more attention than the headline number.

    1. The Question: What Does Long Context Actually Solve?

    Once AI coding tools moved into long-horizon tasks, “how big is the context window” became the default marketing claim. From an engineering standpoint, though, what determines whether a long-horizon task succeeds is not the advertised upper bound. It is whether the model can maintain a stable behavioral pattern as it approaches the window boundary, and whether the execution framework can pick up seamlessly after context compaction.

    One common misconception needs clearing up first: a large context window does not mean the model will continuously and proactively restate early information. The more common behavior is “quiet memory” — the model does not repeatedly emphasize upfront constraints, but it can retrieve and apply them correctly when needed. For developers, this is actually the ideal state: no output budget wasted on re-confirming rules, and no constraints lost at critical moments.

    2. Real Behavior in the 100K–200K Range

    In most routine engineering scenarios, a context of 100K to 200K tokens is enough to cover the core files, interface definitions, and task description of a mid-sized codebase. In testing, this range generally shows no noticeable capability degradation, in three specific ways:

    1. Instruction retention: normative information written early (project conventions, directory structure notes, code style requirements) can still be referenced correctly during long execution.
    2. Stable tool calls: multi-turn file reads and writes, retrieval, and command execution do not fall into disorder as the context grows.
    3. Style consistency: output style stays coherent with earlier and later turns, with no abrupt “personality drift.”

    Put differently, behavior in this range is best described as “unremarkable but usable”: no surprises, no obvious weak spots, and a sensible default working range for long-horizon tasks.

    3. The Real Pitfall Is Continuation After Compaction, Not Window Size

    Long-horizon tasks almost inevitably trigger context compaction; strictly speaking, a task that never triggers compaction does not qualify as long-horizon. The risk concentrates after compaction:

    • State loss: if the compaction summary keeps only the conversation text and not the task state, the model repeats steps that are already done.
    • Rule dilution: early rules get condensed into one vague sentence during compaction, and subsequent execution gradually drifts.
    • Failed continuation: the execution framework does not re-inject the working directory, the list of target files, and the acceptance criteria after compaction.

    The engineering answer is to externalize “memory.” The recommended approach is to write process files to disk, with a structure like this:

    1. .task/
    2. goal.md # Task goal and acceptance criteria
    3. progress.md # Done / in progress / to do
    4. decisions.md # Key trade-offs and reasons
    5. artifacts/ # Outputs and intermediate results

    Pair this with a lightweight continuation convention that the execution framework reloads after every compaction:

    1. 1. Read .task/goal.md and progress.md
    2. 2. Verify the workspace state matches the last recorded state
    3. 3. Continue only from the to-do items in progress.md; do not repeat completed steps
    4. 4. Write back to progress.md immediately after each sub-goal is finished

    The value of this mechanism: the context becomes a disposable temporary cache, the real state is carried by the file system, and no number of compaction triggers can stall the task.

    4. Differences in Retaining Rule-Based Information

    Models differ in how sensitive they are to “early rules.” Some keep looking back at the specification document from the very beginning, hard and repeatedly, throughout a long run, showing up as frequent self-checking; others lean toward quiet memory. The former is steadier in heavily regulated projects, the latter flows better in open-ended exploration. The engineering recommendation: write hard constraints into process files and enforce checks at key checkpoints, rather than relying on the model’s spontaneous memory.

    Also, coding-specialized versions tend to be more restrained in language style, with output closer to “tool-like” phrasing, while general-purpose versions are more flexible. This is a positioning difference, not a judgment of capability.

    5. Cross-Model Collaboration and Version Drift

    Because mainstream models have all been specifically optimized for long context and long-horizon tasks, most of them can hand off to one another within the 100K–200K range: one model handles planning and the skeleton, another takes over implementation and verification, at very low handoff cost. Note that model iteration is fast, and chain-of-thought length and output style can both change after a version update. Evaluation conclusions should therefore carry an expiry date, and a rollback-capable baseline configuration should be kept.

    6. Conclusion: Put the Attention Back on the Harness

    Rather than agonizing over whether the advertised window is 200K-plus or a million tokens, put the investment into the execution framework: writing process files, continuing after compaction, and making acceptance criteria explicit. Get these three right, and long context stops being a source of risk and becomes a predictable, ordinary resource.