AI Agents with Million-Token Context: Can They Handle the Dirty Work?

    This article examines whether AI coding agents with million-token context windows can take over tedious, high-friction engineering work. It explains why generating a patch is not the hard part, what long context does and does not solve, and how context engineering, layered verification, least-privilege sandboxes, and observability turn an agent from a code generator into a reliable deliverer. It also outlines a six-step workflow with machine-checkable artifacts and practical rollout advice.

    1. The Hard Part Is Not Writing the Patch, It Is Closing the Loop

    Hand an AI coding tool a bug ticket and it will usually produce a patch snippet within minutes. The real grind comes afterward: when tests fail, someone has to narrow down the cause over and over; logs are scattered across multiple places and must be cross-referenced; the regression scope is hard to draw; and before committing, the description and verification evidence still need to be filled in.

    So the evaluation criterion has to change. Do not ask whether the tool can generate code. Ask whether it can reliably complete the full loop of locate, modify, verify, and deliver without step-by-step prompting from a human.

    2. What Million-Token Context Changes, and What It Does Not

    The value of an extremely long context window is that it can hold more material at once: larger code slices, complete call chains, historical defect records, runtime logs, and interface contracts. What it reduces is the communication cost of repeatedly feeding material in, and it makes cross-file reasoning more coherent.

    It does not solve three things. First, attention dilution: critical constraints can get buried. Second, the material itself may be wrong or outdated. Third, “read” is not the same as “verified.” Context length is a necessary condition, not a sufficient one.

    3. Context Engineering: From Stuffing It Full to Selecting the Right Pieces

    In practice, build a layered context. The stable layer holds architecture constraints and coding standards. The task layer holds the bug ticket, reproduction steps, and acceptance criteria. The evidence layer holds logs, metrics, and failing test cases. The temporary layer holds the hypotheses for the current round. Pair this with retrieval that loads material on demand instead of injecting everything.

    Illustrative layout:

    1. [Constraints] Do not change public interface signatures; error handling follows the unified return structure
    2. [Task] Reproduction steps, expected behavior, acceptance commands
    3. [Evidence] Failing cases, relevant log excerpts, scope of recent changes
    4. [Hypotheses] Suspected causes for this round, to be verified or refuted

    4. From Patch to Delivery: Breaking the Dirty Work into Acceptable Steps

    Split the work into six steps and leave a trace at each one: reproduce, locate, minimal change, verify, regression, delivery notes. Every step must produce an artifact a machine can judge, such as a reproduction script, an impact list, test output, or a change summary. Move to the next step only when the evidence from the previous one is complete, which avoids the “looks fixed” trap.

    5. Layered Verification: One Green Run Is Not the Finish Line

    Use four verification layers: unit-level to check core logic; integration-level to check cross-module contracts; scenario-level to check end-to-end flows; and non-functional to cover performance, security, and compatibility. When something fails, require the tool to return a minimal reproduction and a list of hypotheses rather than retrying blindly. For randomness risk, fix random seeds and dependency versions so runs are repeatable.

    6. Permissions and Sandboxing: Able to Work, Unable to Wreck Things

    Dirty work often involves high-risk operations. Default to least privilege, run builds and tests in an isolated environment, put manual approval gates on destructive, migration, and release actions, and keep an audit record of every command and file change. This preserves speed while keeping the blast radius acceptable.

    7. Observability and Cost: Make the Process Replayable

    Record an input summary, decision rationale, commands, and results for every agent step to form a replayable trace. Combined with logging services and monitoring alerts, set thresholds for failure rate, retry count, per-task duration, and resource consumption. On cost, do not look only at call volume; look at rework rate too. Less rework is what actually saves money.

    8. Rollout Advice and Conclusion

    Start with low-risk tasks whose outcomes can be judged automatically, such as defect reproduction, test backfilling, and log triage; expand to cross-module refactoring once the process matures. If you need elastic compute and isolated environments, general-purpose cloud capabilities such as container platforms, object storage, message queues, logging services, and monitoring alerts can be organized along the same lines, including on Baidu AI Cloud.

    The conclusion: million-token context brings agents closer to being deliverers, but what actually lets them carry the dirty work is engineering discipline: context engineering, layered verification, permission boundaries, and observability.