Shipping Coding Agents in Production: The Hard Work Starts After the Patch

    Many teams judge coding agents by whether they can generate a diff. This article argues that real engineering begins after the patch: writing verifiable task specs, layering long context by evidence, running propose-verify-converge loops, enforcing least-privilege boundaries, and keeping human gates for release decisions. It covers how to turn bug tickets into executable tasks, use long context without turning it into noise, build a quality loop with failure proofs and regression checks, decide which work to delegate, and avoid common failure patterns when rolling out coding agents.

    Shipping Coding Agents in Production: The Hard Work Starts After the Patch

    1. The Problem Isn’t “Can It Write a Patch”

    Many teams form their first impression of a coding agent from an impressive demo: paste in the failure description, the relevant files, and the error output, and a few minutes later you get a plausible-looking diff. The demo ends there — but the engineering has only just begun.

    A real bug ticket typically contains four kinds of information: symptoms, reproduction conditions, impact scope, and hypotheses already ruled out. If the agent latches onto only the most conspicuous line in the error message, it easily produces a patch that “compiles, sounds explainable, but cannot be proven to fix the problem.” The hard work after the patch includes: filling in failing test cases, running regressions, checking boundary conditions, updating docs and change notes, re-verifying in a constrained environment, and — when fixes fail — narrowing the change surface instead of piling on more code.

    So the right way to evaluate a coding agent is not “did it produce a diff,” but “can it drive a change to a repeatable pass standard?” That is also where long context delivers most of its value: it lets the model see more of the call chain, tests, and constraints at once, reducing guesswork from fragments. It does not replace the execution environment, and it certainly doesn’t replace human judgment about release risk.

    2. Write Bug Tickets as Executable Tasks

    A coding agent is not a ticketing system. Throwing a colloquial bug report at it is the same as letting it guess the acceptance criteria. A safer approach is to first converge the task into structured input.

    We recommend fixing the following fields:

    1. Target behavior: What users or callers should observe after the fix, written as assertable statements — not “optimize this” or “handle the exception.”
    2. Reproduction steps: Inputs, prerequisite data, trigger order, and the expected-vs-actual difference.
    3. Impact scope: Modules, interfaces, data writes, async tasks, or external dependencies involved — plus explicit “do not touch” zones.
    4. Constraints: Backward compatibility, performance budget, error-code semantics, log fields, whether new config switches are allowed.
    5. Definition of done: Which tests must pass, which checks must show no new warnings, the maximum diff size, whether migration notes are required.

    An illustrative task description can be short but decidable:

    Task: Fix “duplicate booking on repeated submission.”
    Must preserve: Existing endpoint path and success response fields unchanged.
    Forbidden: Touching modules outside the settlement main flow; loosening authentication.
    Done: A new concurrent duplicate-submission test case is added and passes; the existing accounting regression suite passes; the change note states the root cause and uncovered risks.

    Written this way, every step the agent takes can be checked against the spec, instead of endless “take another look” in the conversation. If information is insufficient, the agent should list what’s missing and stop touching code — not fill the gaps with assumptions.

    3. How to Use Long Context Without Turning It Into Noise

    Once context windows got larger, a common misuse was stuffing the entire repository, logs, and documentation into the prompt. The window fitting everything does not mean attention is allocated correctly. The effective approach is layered provision, not indiscriminate piling.

    Layer one — locating material: the error stack, the relevant interface contracts, the failing test case, and the most recent related change note. The goal is to help the model form a “suspect range,” not to start editing files immediately.

    Layer two — evidence material: the named source files, callers, meanings of config items, data constraints. Attach only snippets directly related to the suspect range, with paths and responsibilities labeled. Irrelevant generated code, historical discussions, and duplicate logs dilute the critical constraints.

    Layer three — acceptance material: how existing tests are organized, which cases represent the regression baseline, how to run them locally or in the pipeline. Without this layer, the model tends to write something that “looks like a test” but cannot plug into the real engineering process.

    In practice, adopt a “retrieve first, then read, then modify” rhythm: narrow down to a small set of files based on symbols, error text, and directory responsibilities; read the invariants in those files (idempotency keys, state machines, transaction boundaries); propose a minimal-change hypothesis; only then generate the diff. After each round, write confirmed conclusions back into the task description so the next round doesn’t restart from the raw logs.

    Long context is well suited for “cross-file consistency” — for example, when an enum extension must be synchronized across validation, persistence, and display. It is not a substitute for dependency-analysis tooling. Facts obtainable from static search, failing-test lists, and call graphs should be fed in as facts, not reconstructed from the model’s memory.

    4. The Quality Loop After the Patch

    A generated diff is only a candidate. A reliable process confines the agent to a “propose — verify — converge” loop, with the environment providing hard feedback.

    1. Minimal changes. Fix the root cause rather than wrapping everything in a catch block. If the root cause is a missing idempotency or state check, add the check and the test — don’t swallow all exceptions just to turn the current case green. The diff should be reviewable within ten minutes. Anything larger usually means the task wasn’t decomposed, or the model is refactoring on the side.

    2. Failure proof first. For defect tasks, have the agent write or point to a check that currently fails before changing the implementation. Without a failure proof, you can’t distinguish “it’s fixed” from “the test was written wrong so it went green.”

    3. Layered verification. From near to far: checks targeting this defect, regression on affected modules, smoke tests on critical paths. Put what runs fast locally first, and leave expensive full-suite checks until the candidate is stable. Feed failure logs back in full — but only failures related to this change, so the model isn’t derailed by unrelated red lights.

    4. Separate explanation from risk. Require three distinct outputs, never blended: what was changed, why the change maps to the root cause, and which scenarios remain uncovered. Uncovered areas should be stated as explicit limitations — e.g., “cross-day reconciliation not verified” — rather than hidden behind a confident summary.

    5. Human gate. Before merging, someone familiar with the module must confirm: whether the behavior change is acceptable, whether data consistency is touched, whether a feature flag or staged rollout is needed. The agent can draft the change note, but it cannot declare the change releasable itself.

    An illustrative loop doesn’t need to bind to a specific toolchain; the logic is fixed:

    1. Read the task and constraints
    2. List suspect files and invariants
    3. Provide a failing case or point to an existing failure
    4. Submit a minimal diff
    5. Run the agreed checks
    6. On failure, modify only based on the failure evidence and record attempted paths
    7. On pass, output risks and rollback points

    If two consecutive rounds fail to narrow the failure scope, stop automated modification and hand the contradiction back to a human: the environment data may be wrong, the requirements may conflict, or the defect may not live in the current repository at all.

    5. Permission, Data, and Environment Boundaries

    A coding agent can read code, modify files, and run commands — so permissions must default to least privilege.

    • Code and secrets: Passwords, certificates, and connection strings in the repo must never enter prompts. Sanitize logs before providing them. An agent does not need write access to a production database to fix an application defect.
    • Execution environment: Tests should run against isolated dependencies and data, using fixed fixtures or disposable instances. Never copy production traffic or real user data into the conversation “for convenience of reproduction.”
    • External side effects: By default, do not allow the agent to deploy, change production configs, or call billing or messaging APIs. When integration is needed, use a dedicated sandbox and fake implementations, with permitted operations whitelisted.
    • Supply chain: Be extremely cautious with automatically introduced dependencies. If the job can be done with existing libraries, add none; when a new dependency is unavoidable, a human should review the source, license, and maintenance status — not have the model write it straight into the manifest.
    • Traceability: Preserve the original task, the context list used, the diff, check results, and human conclusions. When something goes wrong, you need to answer “what was the basis for this change?” — not be left with an unreproducible chat transcript.

    These boundaries aren’t distrust of the model; they acknowledge that models can confidently go wrong. The clearer the permission lines, the more of the messy work the agent can safely take on: adding tests, correlating logs, renaming, drafting migrations, tidying review comments — all delegable. Touching production or money-moving paths must stay behind the human gate.

    6. What Work to Delegate

    Good fit: Tasks with concentrated defect clues, automatically decidable acceptance criteria, and enumerable change surfaces. Examples: null pointers and boundary conditions, inconsistent error codes, duplicate writes caused by missing idempotency, doc–implementation drift, and backfilling tests for legacy functions.

    Use with caution: Issues whose behavior depends on production timing, data distribution, or external-system semantics. The agent can help organize timelines and hypotheses, but conclusions must rest on repeatable experiments.

    Do not delegate end-to-end: Loosening security policies, redoing permission models, changing cross-team protocols, or core accounting with no test baseline. The agent may draft the plan and checklist; execution and trade-offs remain with humans.

    Teams should pilot on one category of low-risk, high-repetition tickets, recording the time from task intake to passing checks, the number of reworks, and the proportion of human edits. If the metrics improve, expand scope; if they don’t, improve task writing and verification first — not just more context.

    7. Common Failure Patterns in Rollout

    • Only looking at generation speed. Fast just means drafting is cheap. If rework and review time goes up, the whole thing is slower.
    • Treating one conversation as the knowledge base. Constraints that exist only in chat are lost by the next task. Distill them into repo-hosted task templates, test conventions, and module docs.
    • Using longer context to mask a dirty repository. Confusing naming, tests that can’t run independently, unclear module boundaries — the model will edit the wrong files more often. Cleaning up the baseline beats a bigger window.
    • Retrying indefinitely after failure. Without stop conditions and an attempt log, the agent spins on the same hypothesis and drags in unrelated refactoring.
    • Equating passing tests with correctness. Tests only cover the assertions someone wrote. For money, permissions, and data deletion, add manual invariant checks — e.g., “a repeated request must not create a second record.”

    8. Summary

    Coding agents can take on the tedious, gritty work of fault localization, patch drafting, test backfilling, and documentation cleanup — provided that tasks are decidable, context is layered by evidence, verification is executed by the environment, and permissions are off by default. Long context expands what can be cross-checked in one pass, but whether delivery is reliable depends on what comes after the patch: the failure proof, the regression run, the risk statement, and the human gate. Write the definition of done clearly, keep the model and the humans each within the range they can be responsible for — and the coding agent becomes a stable link in the engineering process, not just a demo-time coding assistant.