Long-Context Coding in Practice: Reliable Continuation and Common Pitfalls
Long context windows of 100K to 200K tokens are often sufficient for repository-scale coding, but capacity alone does not guarantee reliable long-running work. This article explains how models handle early rules, why compaction must be treated as a normal workflow event, how to preserve progress across context resets, and how to evaluate long-context coding systems based on continuation quality rather than advertised window size.
In coding assistants and agent workflows, context windows have expanded from tens of thousands of tokens to 100K or even 200K tokens. For many real-world projects, 200K tokens is enough to cover repository documentation, multi-file changes, tool outputs, and a long conversation history. Beyond that, however, a larger window does not solve an unstable harness or a process that is never persisted. Long-running tasks can still lose track of their state after compaction.
This article brings the discussion back from “which model has the largest context window?” to engineering practice: how models handle rules introduced early in a task, how they resume after compaction, and whether capability declines noticeably in the 100K–200K range.
What Long Context Actually Means for Coding
Coding tasks typically combine several types of context:
- Project conventions and role instructions
- Directory structures and API summaries
- The current diff
- Tool outputs
- Constraints added by the user over time
These materials are not equally important. Rules near the beginning often define style requirements and prohibited actions. Tool results in the middle provide factual evidence. The latest user instruction usually determines the next step.
“Remembering the context” does not mean reciting the entire conversation. It means continuing to follow early constraints, referring to intermediate facts, and avoiding endless loops caused by an overly long history.
In practice, two behavior patterns are common. Some models do not repeatedly mention the initial instructions, yet still follow them while editing code and writing tests. This feels like quiet, reliable compliance. Others repeatedly and explicitly refer back to the opening rules. That can be useful in repositories with many constraints where even small deviations are unacceptable.
Neither behavior is universally better. The right choice depends partly on the harness. Does it place the rules in the system prompt once, or does it expect the model to restate them on every turn?
The main risk is treating an “ultra-long context window” as a universal advantage for long documents. Window size measures capacity. It does not directly measure stability or rule adherence. A model that leads in context capacity for a period of time is not necessarily the best model for long-running coding tasks today. Training data and secondary fine-tuning can also preserve outdated marketing claims, causing a model to repeat them even when current evaluations tell a different story.
The 100K–200K Range Is Usually Enough for Coding
For repository-level changes, multi-file refactoring, and agent loops with tool calls, effective context often falls between 100K and 200K tokens. This range does not usually produce a dramatic “the model becomes unintelligent as the window gets longer” effect.
More common problems include:
- Attention being diluted by verbose logs
- Early rules being buried under later noise
- Reasoning becoming less detailed after a truncated or compressed history
If the model appears less willing to expand its reasoning but is not making obvious factual or implementation errors, it is better to interpret that as a change in model iteration or decoding strategy rather than simply concluding that the model has become less capable.
Models fine-tuned specifically for coding often produce more focused language, less small talk, and fewer digressions. They behave more like tools. General-purpose conversational models may be more flexible but can introduce unnecessary rhetoric. For long-running tasks, the more tool-oriented style is often more efficient and less prone to drifting.
Model selection should therefore not be based solely on the conversational impression of a model family. Instead, evaluate whether the model:
- Continues to follow AGENTS-style repository conventions after compaction
- Remembers verbal constraints that were never written to a file
- Resumes unfinished work without repeating completed steps
Verbal constraints are inherently unreliable. Important requirements should be written into a process file as early as possible.
The Reality of Long-Running Tasks: Compaction Will Happen
A genuinely long-running task is not one that fills a context window once. It is a continuous process that may run for hours and pass through multiple compaction events. If compaction never occurs, the task may simply not be long enough to test the workflow.
Once compaction happens, the model may see a summary or a truncated context instead of the original conversation. Details that previously remained available in the window can disappear. The harness must therefore support correct continuation after compaction by restoring:
- The task objective
- Completed steps
- Outstanding work
- Important file paths
- Validation and verification commands
Persisting the process to files is currently one of the most reliable approaches. Store phase objectives, decisions, failed attempts, pending tasks, and acceptance criteria in a progress document or structured log inside the repository. After compaction, the next cycle should read this file before making further changes.
Object storage or an external logging service can provide backups and auditing, but the primary path should remain visible in the workspace. This avoids keeping critical state only inside the session.
A task involving 147 million tokens may be impossible for a human to read end to end, but for a system it is simply the accumulated result of multiple compaction cycles. Without persisted state, a large token count can create the illusion of continuity without providing reliable progress.
A continuation checklist can be concrete:
- The task ID is consistent before and after compaction
- The progress file has a verifiable hash or version
- Tool permissions and the working directory are preserved
- The rule document remains available on the system side or is explicitly injected again
If any of these items is missing, the task can drift long before a five-hour wall-clock limit is reached. The time limit is only an outer boundary. In practice, the highest risk often appears at the compaction point.
Rule Memory: System Prompts, Fine-Tuning, and Explicit Recall
Opening instructions such as coding standards, directory restrictions, and prohibited actions can remain “remembered” in a long context without being applied consistently.
Some models repeatedly bring these rules back into their responses and align their edits with them, creating the impression that they have been specifically optimized for coding rules. Other models follow the rules quietly without restating them.
Engineering systems should not depend on a model’s communication style. A more reliable design is to:
- Keep rules short and easy to retrieve
- Separate rules from the progress file
- Enforce critical restrictions at the tool layer, such as blocking changes to a protected directory
- Use scripts during review to check compliance instead of relying only on generation-time behavior
When tool JSON and build logs fill the window, the relative weight of the rules can be diluted. Periodically reinjecting the rules, or requiring a short rules file to be read after every compaction, is often more effective than relying on a million-token context window.
The industry sometimes turns a long-context advantage from a particular period into a permanent label. Later models may absorb those claims through training data, creating a kind of “context-size inequality”: the assumption that a larger window must always mean a stronger model. Developers should evaluate reliable continuation on current tasks rather than relying on marketing language from previous model generations.
Engineering Pitfalls: Harness Design, Persistence, and Evaluation
Evaluate continuation, not first-turn writing quality.
A vivid first response is irrelevant if the model loses the task list after compaction.Make the compaction strategy configurable.
Preserving the complete rules, the most recent N rounds of tool results, and a summary of the progress file is usually better than applying uniform truncation.Use a fixed process-file template.
Recommended fields include: objective, completed work, outstanding work, risks, and next command. Fixed fields reduce format drift caused by excessive model freedom.Run regressions in the 100K–200K range.
Use the same repository and the same rules, then compare patch quality and rule-violation counts before and after compaction. Do not evaluate systems only by their advertised context size.Monitor compaction and idle loops in cloud environments.
Session logs and progress snapshots can be stored in object storage. Monitoring should alert on compaction failures and repeated no-progress cycles. Capability descriptions should remain generic rather than depending on a vendor-specific interface name.
Conclusion
Mainstream coding-oriented models are increasingly optimized for long context and long-running tasks. For everyday coding loops in the 100K–200K range, they are generally sufficient and reasonably reliable.
The real differences usually come from three areas:
- Whether early rules continue to be followed
- Whether the harness can resume correctly after compaction
- Whether the process is persisted in the workspace
Context-window numbers will change. Persistence and reliable continuation will remain important. Replacing marketing claims about a “killer feature” with repeatable compaction-and-resume tests is what turns long context from a specification into actual engineering capacity.
