LLM Long Context and Long-Running Tasks: Practical Findings and Engineering Pitfalls
How well do coding LLMs handle 200K-token contexts, and what happens when a task spans millions of tokens? This article examines practical differences in rule retention and agent orchestration, then explains how persistent state files, context compaction, and harness controls help keep long-running tasks on track. The central takeaway: reliable execution depends on engineering discipline, not just the advertised context window.
Long-context support has become a standard feature in large language model (LLM) application development. Yet as model sizes and context windows grow, questions about their real-world performance have become more pressing.
Some models gained an outsized reputation by supporting long text earlier than their competitors. Promotional articles described that capability as a defining advantage. When such material later entered model training datasets, models themselves sometimes repeated the claim that long-text processing was their “secret weapon.”
That reputation is not a substitute for practical evaluation. What is it actually like to work with a 200K-token context—or a context window advertised at one million tokens? And which engineering pitfalls matter most?
This article examines those questions through practical observations and implementation considerations.
1. Practical Performance at 200K Tokens
In the practical use described here, mainstream coding LLMs remained usable and stable at around 200K tokens, without an obvious deterioration in capability. However, they differed substantially in how they retained context and organized long-running work.
Agent Orchestration and Memory Strategies
Some leading model-based systems favor subagent orchestration rather than carrying out every step within a single growing context. A coordinating agent distributes work, while subagents execute specific parts of the task. This helps limit the expansion of any individual context window.
In practice, these systems can exhibit a form of unobtrusive memory: they do not repeatedly restate earlier instructions, but still follow them during execution.
That quiet consistency resembles the working style of an experienced developer. Users may also find it straightforward to continue collaborating with another mainstream model that exhibits similar behavior.
Stronger Recall of Coding Rules
Other model iterations take a noticeably different approach. They repeatedly return to the rules established at the start of a task, including project guidance in files such as AGENTS.md.
Compared with earlier versions, some show a substantial improvement in recalling and following coding rules. This behavior suggests focused optimization for instruction adherence in software development.
For enterprise projects with strict coding conventions, stronger rule retention can help reduce drift in code style as a task progresses.
Side Effects and Uncertainty Across Model Updates
These observations have a short shelf life. With models evolving rapidly, a conclusion that holds today may no longer apply a month or two later.
For example, a general-purpose version may use lively language and occasional humor, while its coding-specialized counterpart becomes much more rigid and task-focused.
Quiet updates can also change behavior. Some models may show no obvious decline in capability while producing substantially shorter visible reasoning traces. That could reflect changes in underlying reasoning behavior, although the visible output alone does not establish what changed.
Such uncertainty makes ongoing evaluation important. Model selection should be a recurring process, not a one-time decision.
2. Long-Running Tasks: Context Compaction and State Management
When a task involves cumulative processing on the order of 147 million tokens, the challenge is no longer simply fitting more text into a prompt. It becomes a problem of managing work over an extended sequence of interactions.
At that scale, context compaction is unavoidable. In the sense used here, a genuinely long-running task exceeds what can remain in one active context; a task completed without compaction has not reached that boundary.
The main concern is information loss after compaction. However, with an appropriate architecture, a limited context window does not have to prevent continued execution.
Persist Intermediate State to Files
The most important engineering practice is to establish a reliable mechanism for writing task state to persistent files.
An agent should not keep all intermediate information solely in its transient context window. Through tool calls, it should save critical decisions, completed steps, error logs, and other relevant state to durable storage.
In a cloud-native architecture, general-purpose object storage or file storage can support this mechanism. Task state, variable mappings, and execution progress can be stored as structured data, such as JSON or Markdown.
After substantial context compaction, the agent can read those files before its next step and reconstruct the working context it needs to continue.
The distinction is important: the context window is a temporary workspace, while persistent files preserve continuity across successive workspaces.
Use the Harness to Control Compaction and Recovery
The application harness—the control layer around the model—must ensure that execution can continue correctly after compaction. This requires detecting context growth and reloading saved state.
The following simplified pseudocode illustrates the control flow:
class LongTermTaskHarness:def __init__(self, llm_client, max_context_tokens=200000):self.llm = llm_clientself.max_tokens = max_context_tokensself.current_tokens = 0def execute_task(self, prompt):while not self.is_task_complete():# Check whether the context is approaching the compaction thresholdif self.current_tokens >= self.max_tokens * 0.8:print("Triggering context compaction...")# Instruct the model to persist its current stateself.llm.invoke("Write the current progress and key state to state.json, ""then output 'READY_FOR_COMPACT'")# Clear conversation history while retaining the base rulesself.llm.clear_history()# Reload the saved context from the state fileself.llm.load_context_from_file("state.json")self.current_tokens = self.llm.estimate_tokens()# Continue with the next stepresponse = self.llm.invoke(prompt)self.current_tokens += self.llm.estimate_tokens(response)self.process_response(response)
This is illustrative pseudocode, not an implementation against a specific LLM SDK. The client methods and task-processing methods represent responsibilities that the application must provide.
Here, the harness acts as a supervisor. When the context approaches its threshold, it directs the model to save state, clears the accumulated history, and rebuilds the context from persistent information.
The architecture is intended to prevent context overflow from interrupting long-running work. Its effectiveness depends on the harness correctly managing persistence and recovery, rather than merely issuing a request to save state.
3. Context Size Matters, but Engineering Matters More
Mainstream coding LLMs have received focused optimization for long-context processing and long-running tasks. In the practical observations discussed here, they were generally reliable within the 100K–200K-token range. Developers therefore need not treat a large context as inherently problematic.
However, a model’s advertised window—whether 262K or one million tokens—is not the decisive factor in completing an extended task. The application’s engineering is more important.
Persistent process files, explicit state-machine control, and a robust harness provide the foundation for reliable execution. Suitable orchestration, cloud-native storage, and logging and monitoring services support that foundation.
The practical lesson is to move beyond the idea that long-text capability alone is a decisive advantage. With disciplined state management and recovery, current systems can support tasks involving millions of tokens across multiple contexts and turn long-context LLMs into useful development tools.
