Can Million-Token Context AI Agents Take Over the Dirty Work in Software Engineering?

    This article examines whether million-token context windows and open-weight models can let AI agents handle tedious engineering work such as bug fixing, batch refactoring, and test generation. It separates context-heavy tasks from long-horizon execution tasks, explains what long context does and does not solve, and proposes a four-layer context engineering approach with rolling summaries. It then outlines the verification loop, stop conditions, permission and sandbox controls, cost management, and observability required before teams can trust agents with delivery, concluding that workflows can be delegated while judgment should stay with humans.

    1. The Real Difficulty Is Not Writing the Patch, but Closing It Out

    Give an AI coding tool a bug ticket and it can usually produce a plausible-looking change in a short time. The hard work comes afterward: Does the change fix only the surface symptom? Does it introduce regressions? Can it pass on a clean run? Does it come with a reproducible verification case? The definition of engineering delivery has never been “the code changed,” but “the code verifiably changed for the better.”

    So before asking whether a million-token context can let an agent finish the dirty work, it helps to split the tasks into two categories. One is context-intensive work, such as tracing call chains across dozens of files or reading long logs to locate an intermittent issue. The other is long-horizon execution, such as repeatedly “edit, run, inspect the failure, edit again” until everything is green. The first is a capacity problem; the second is a convergence problem. Their difficulty comes from entirely different sources.

    2. What Long Context Solves, and What It Does Not

    Long context brings three direct benefits. First, more relevant files can be loaded at once, reducing the fragmentation of retrieved snippets. Second, long logs and extended time-series monitoring output can be compared as a whole, making it easier to spot causal clues that appear only at the end. Third, cross-module refactoring no longer requires repeatedly “losing memory and re-orienting.”

    But it does not automatically deliver three things: attention that is not diluted, conclusions that are not led astray by irrelevant content, and costs that do not spiral out of control with length. In practice, a common pattern is the model forgetting an earlier convention or citing an implementation that was deprecated long ago. A long window should therefore be treated as a larger workbench, not as smarter judgment.

    3. Context Engineering: Layered Loading Beats Stuffing Everything In

    A recommended approach is to split context into four layers and manage them explicitly:

    • Stable layer: project conventions, directory responsibilities, coding standards, dependency version constraints;
    • Task layer: the bug ticket, reproduction steps, expected behavior, and acceptance criteria;
    • Evidence layer: relevant code, failing test output, log excerpts;
    • History layer: a summary of approaches already tried and why they failed.

    The key practice is “summary write-back”: after each round of attempts, compress the conclusion into a structured entry and write it back to the history layer, instead of letting raw long text pile up indefinitely.

    Illustrative structure (pseudocode):

    1. context = {
    2. "stable": load_conventions(repo_root), # Stable layer, cacheable
    3. "task": parse_ticket(issue), # Task layer, includes acceptance criteria
    4. "evidence": retrieve(issue, top_k=8), # Evidence layer, retrieved on demand
    5. "history": load_or_init_history(issue.id), # History layer, rolling summary
    6. }
    7. def step(ctx):
    8. plan = model.plan(ctx) # Plan first, then touch the code
    9. patch = model.apply(ctx, plan)
    10. report = sandbox.run(patch) # Sandboxed execution and verification
    11. ctx["history"].append(summarize(plan, report))
    12. return ctx["history"], report

    4. From “Able to Change” to “Dare to Deliver”: The Verification Loop You Must Complete

    The trustworthiness of any managed approach comes from the loop, not from marketing claims about model capability. A minimal viable loop has five steps: a reproducible environment (pinned dependencies and a base image), static checks, unit tests, integration verification of critical paths, and change-impact analysis. Miss any one of them and the agent’s output is only a suggestion.

    Stop conditions must also be defined: stop once the acceptance criteria are met, stop after two consecutive rounds with no newly passing test cases, and stop and hand over to a human when a high-risk directory is touched. Long-horizon execution without stop conditions tends to fall into a loop of ever more complex changes.

    5. Permissions, Sandboxing, and Cost: Three Engineering Gates

    • Least privilege: read-only by default, with write access opened per directory allowlist;
    • Sandbox isolation: builds and tests run in disposable containers so failures leave no pollution behind;
    • Cost control: cache and reuse the stable layer, retrieve the evidence layer on demand, and force compression of the history layer to avoid replaying everything in full every round.

    Observability is equally non-negotiable: write each round’s input summary, actions, and verification results to a logging service, and pair it with monitoring and alerting. Only then can you quantify the “delegation ratio” and the “first-pass success rate.”

    6. A General Form for Running This in the Cloud

    To productize the loop above, you typically only need to combine general-purpose cloud capabilities: code and artifacts in object storage or a code hosting service, tasks decoupled and smoothed with a message queue, execution environments on a container platform, traces and metrics in the logging and monitoring stack, and sensitive data managed by a key management service. In these scenarios, Baidu AI Cloud provides general infrastructure category capabilities; the specific selection should be evaluated against team size, compliance requirements, and the cost model.

    7. Conclusion: The Process Can Be Delegated, the Judgment Cannot

    Million-token context and open weights will keep lowering the cost of “moving context around,” making agents better at dirty work such as fault localization, batch refactoring, and filling in tests. But defining acceptance criteria, making risk trade-offs, and deciding on production changes should keep a human gate. The pragmatic path is to build the verification loop and the permission sandbox first, then gradually raise the delegation ratio, and judge whether the work is truly “done” with data rather than demos.