Can Coding Agents Finish the Dirty Work? Long Context, Open Weights, and the Agent Loop
Coding agents can produce a patch in minutes, but real engineering work continues long after that: running tests, reading logs, tracing side effects, and confirming nothing regressed. This article explains what million-token context windows actually change, what open-weight model deployment buys engineering teams, and why the distance between "writes a patch" and "finishes the job" is closed by an agent loop with tool access and feedback — not by a bigger model. It also covers the practices that make such agents reliable in practice, including verifiable stopping conditions, small task decomposition, feedback quality, and human review, along with the security boundaries required before running any of it.
Starting From a Bug Ticket
Hand a coding assistant a bug ticket and it can return a patch in minutes. The scenario itself is nothing new. What actually frustrates engineers is rarely the patch — it is everything that comes after: running the test suite, reading logs, tracing collateral effects, confirming no regression slipped in. Generating code is only the first step in a much longer pipeline.
As context windows grew from a few thousand tokens to the million-token range, and as open weights added freedom in how models are deployed, one question keeps coming back: can agents finally take the dirty work off our hands? This article looks at the question from two angles — the technical mechanism and the engineering practice — and tries to stay grounded in what actually works today.
What Long Context Actually Solves
Conventionally, large models face an awkward problem with big codebases: the code far exceeds the context window. Engineers chop the repository into fragments and feed them in piece by piece, and that chopping itself destroys cross-file relationships. Whether a function is correct may depend on a contract declared by an interface three call levels away. The blast radius of a change may sit in a module that never shared a window with the code you modified.
Long context changes exactly this. When a model can “see” enough related code within a single inference pass, it becomes possible to:
- reason about cross-file type dependencies and interface contracts instead of viewing a function in isolation;
- follow call chains and assess the downstream impact of a change;
- consult requirement docs, commit history, and tests at the same time, and reach judgments closer to how the project is actually built.
One caveat deserves emphasis: long context is not a matter of “make the window bigger and the problem is solved.” The longer the context, the more information density matters. With too much irrelevant material, the model can be pulled off course by noise. In practice, retrieval augmentation, relevance ranking, and loading context on demand often matter as much as window size. A long window provides the possibility; good context organization determines the result.
The Engineering Value of Open Weights
Open weights mean the model’s parameters can be obtained and deployed, which brings a few practical benefits:
- Data control. Enterprise code often touches commercial secrets, and sending fragments to an external service raises compliance concerns. Running locally or in a private environment keeps data inside the boundary — which matters a great deal in finance and the public sector.
- Predictable cost. Large-scale, high-frequency code analysis generates substantial call volume. Deploying on your own compute shifts the marginal cost from “billed per call” to “spent on resources,” which is easier to forecast under steady load.
- Customization. Open weights allow continued training or fine-tuning on code from a specific domain, so the model better understands your team’s frameworks, conventions, and historical style.
Open weights also mean the organization takes on model serving, inference optimization, and hardware operations itself. Whether to self-host depends on team size, security requirements, and load characteristics. There is no universal answer.
The Gap Between a Patch and a Finished Task
Back to the original question: why does “can write a patch” still fall short of “can finish the dirty work”?
Because real engineering work is a closed loop, and generating a patch is only one node in it. A complete task flow usually looks like this:
- Understand the problem: read the ticket, locate the relevant code;
- Propose a fix: describe the approach or produce a patch;
- Verify correctness: run tests, build, run static checks;
- Handle failures: iterate based on the errors;
- Confirm no regression: make sure the change did not break something else;
- Submit and document: tidy up the diff, update docs.
A large model is fundamentally a function that takes text in and returns text out. It cannot actually run tests, read runtime errors, or adjust based on the results. Closing this gap is not a matter of making the model larger — it means giving it hands and a feedback loop, which is what an agent architecture is for.
The Architecture That Lets Agents Do Real Work: the Agent Loop
The core idea of an agent is to have the model run in a loop of think → act → observe, until the task is done or a termination condition is hit. Illustrative pseudocode:
def run_agent(task, tools, model, max_steps=20):messages = [{"role": "user", "content": task}]for step in range(max_steps):# 1. Let the model pick the next move: answer directly, or call a toolaction = model.decide(messages, available_tools=tools)if action.type == "final":return action.answer # task complete# 2. Execute the tool call and get the real resultobservation = tools[action.tool_name](**action.arguments)# 3. Feed the observation back into context and start the next roundmessages.append({"role": "assistant", "content": action.raw})messages.append({"role": "tool", "content": str(observation)})return "Stopped: max steps reached without completing the task"
Steps 2 and 3 are what matter. The model no longer imagines whether tests will pass — it actually runs them and uses the real output as the basis for its next decision. That is the technical foundation for automating the dirty work.
Tool Access and Environment Feedback
An agent’s reach is bounded by the tools it can call. For coding tasks, the common set includes:
- Code retrieval: searching the repository by semantics or symbol to find relevant code, which addresses the “can’t fit all the context” problem;
- Code editing: reading and modifying files;
- Command execution: running builds, unit tests, and static checks;
- Result reading: collecting exit codes, stdout, and error messages.
The security boundary has to be stated plainly here. Letting a model execute commands means running it in a controlled sandbox — an isolated container, a restricted filesystem, restricted network access. Execution rights must never be granted directly on production machines or hosts holding sensitive data. Isolation and auditing at the tool-execution layer is a prerequisite for using agents in production, not an optional extra.
Key Practices for Making It Work in Production
A few practices matter for making agents reliably useful:
- Verifiable stopping conditions. Give the agent an explicit success criterion, such as “the target tests all pass.” Without one, agents easily spin in the loop or wrap up too early.
- Small steps, fast iteration. Rather than asking an agent to refactor a whole module in one shot, break the task into small steps that can be verified independently. Each step can be confirmed with a test run, and a failure is cheap to roll back.
- Feedback quality sets the ceiling. How well an agent iterates depends heavily on the feedback it receives. A clear error message or structured test output is far more useful than a vague “it failed.” Improving the readability of your tests often improves an agent’s self-correction noticeably.
- Keep a human in the loop. Full automation is tempting, but consequential changes should still pass through human review. Agents take on the repetitive, verifiable labor; humans own the tradeoffs that are hard to judge automatically.
A Clear-Eyed View of the Limits
Long context and open weights genuinely widen what coding agents can do, but a few points deserve sober treatment:
- Long context is the opportunity to see more, not a guarantee of seeing correctly. Retrieval quality and context organization remain the deciding factors.
- Open weights lower the data and cost barriers, while moving operational responsibility onto your own team.
- Agents can automate dirty work that is verifiable, but ambiguous requirements, cross-team coordination, and architecture-level tradeoffs still depend heavily on human judgment.
Put differently, a coding agent is closer to an assistant that frees engineers from mechanical labor than to a black box that replaces engineering judgment. What it is genuinely good at is work with a clear right answer that can be checked repeatedly — which happens to be a sizable share of the tedium in everyday development.
Closing Thoughts
The distance between “a patch in minutes” and “actually finishing the dirty work” is filled by a whole engineering system: context organization, tool access, feedback loops, and security boundaries. Long context supplies the wide view, open weights supply a controllable and customizable foundation, and the agent architecture ties these capabilities into a loop. Understanding what this system can and cannot do is what lets coding agents create real value in a project, rather than staying a flashy moment in a demo video.
