Millisecond Context Agents: Can They Take Over the Dirty Work?
This article examines whether million-token context windows enable AI agents to handle the repetitive, high-friction work that follows patch generation: running tests, reproducing failures, adding regression cases, and documenting changes. It explains why larger context alone does not improve task completion, then outlines a practical approach based on context budgeting, layered external memory, tool-based verification loops, observability, and least-privilege execution. Readers will find example budget allocations, a memory entry structure, and pseudocode for a closed verification loop.
1. The Hard Part Is Not Writing Code, It Is Proving the Code Works
Hand an AI coding tool a bug ticket and it will often produce a plausible-looking patch within minutes. The real cost starts after the patch: running tests, reproducing the failure, figuring out whether the problem is environmental or logical, adding regression cases, and writing up the change. This is the dirty work. It is repetitive, tedious, and full of context switching, and the failure signals are often vague.
Expanding the context window from a few thousand tokens to a million brings one obvious change: more can fit in a single view. Key repository files, long logs, API documentation, and historical tickets can all sit in the same field of view. But more capacity does not automatically mean a higher task completion rate, for three reasons:
- Attention dilution: the more candidate information there is, the more likely the model is to cite outdated files or similar but irrelevant implementations.
- Error accumulation: in long-chain tasks, a misjudgment in an early step is treated as established fact by later steps and amplified.
- Externalized verification cost: the model can generate a patch, but it does not naturally have your team’s test environment, permissions, or acceptance criteria.
The engineering focus should therefore shift from cramming more into the context to making the context governable and making verification executable.
2. Context Budget Management: Treat the Million-Token Window as a Scarce Resource
Long context needs a budget system. A practical approach is to split the context into four layers, each with a clear quota and eviction policy:
- Task layer: the bug ticket, acceptance criteria, and constraints (must always stay resident).
- Evidence layer: failure logs, stack traces, and reproduction steps (loaded on demand, summaries retained).
- Code layer: relevant modules, interface definitions, and data structures (retrieved by dependency graph).
- History layer: past fixes and decision records (keep only conclusions and blast radius).
An illustrative budget table (pseudocode):
budget = 1_000_000 tokenstask <= 5% # always resident, never evictedevidence <= 25% # summaries first, raw text retrievablecode <= 50% # dependencies first, similarity secondhistory <= 20% # conclusions and blast radius only
The key principle is “summaries stay resident, raw text remains retrievable.” Do not dump entire long logs into the context. Instead, extract the timeline, exception keywords, first failure point, and last success point, and build an index structure that can be clicked back to the source.
3. Layered Memory: So Long Tasks Do Not Rely on Recall
A million-token context still forgets and mixes things up, so external memory is needed:
- Fact store: file responsibilities, module boundaries, and what configuration items mean.
- Decision store: why a fix was done this way and why alternatives were rejected.
- Failure store: attempts that did not work, to avoid repeating the same mistakes.
A minimal usable memory entry example:
{"task_id": "INC-2024-0117","symptom": "timeouts concentrated at peak hours","verified_root_cause": "connection pool limit too small","change": "raise the limit and add queue metrics","negative_results": ["adding cache did not help", "scaling out did not help"],"rollback_plan": "revert configuration to the previous version"}
4. From Patch Generation to a Closed Verification Loop
For an agent to take over the dirty work, acceptance criteria must be turned into tooling so it can run, read, and judge results on its own:
- Reproduce: trigger the problem reliably with a scripted approach.
- Verify: run unit tests, integration tests, and static checks in layers.
- Regress: confirm existing behavior is not broken.
- Attribute: when something fails, separate environmental, data, and code causes.
- Deliver: produce the change description, blast radius, and rollback plan.
Pseudocode example:
loop:patch = generate(task, evidence, code)result = run(verify_suite, patch)if result.passed and result.regression == "clean":return deliver(patch, report)memory.append(result.failure_summary)
The point here is that the verification suite must be a repeatable, deterministic process. Otherwise the agent will keep rewriting code in response to random failures and generate more noise.
5. Observability and Permission Boundaries
Long-chain automation needs observability: the input summary, tool calls, elapsed time, and failure reason for every step should go into a logging service and a monitoring and alerting system so they can be traced back. For permissions, follow a least-privilege principle: read-only retrieval, execution in an isolated environment, and changes produced as diffs that a human or a pipeline reviews before merging. Compute and storage can run on a container platform and object storage to host temporary environments and artifacts without polluting the main environment.
6. Implementation Advice and Conclusion
- Start with a narrow closed loop: pick one failure type with good test coverage and stable reproduction as a pilot.
- Govern the context before expanding task scope; without budgets and eviction policies, a larger window is less stable, not more.
- Write acceptance criteria as code so the agent has an objective judge.
- Use memory and the failure store to suppress repeated work and error accumulation.
The conclusion is clear: million-token context gives agents a better chance of taking over long-chain tasks, but what really decides success is context governance, tool-based verification, and observability. Get those three right and the dirty work can be handed off reliably. Otherwise, you are just stretching uncertainty across a longer timeline.
