Four Handoff Points for Running AI Coding Agents Overnight

    The real challenge of overnight automation is not how long an agent runs, but how much decision-making authority you hand over. This article breaks down four handoff points—reusable acceptance checks, decidable stop conditions, time-based polling with backoff, and explicit permission tiers—and shows how to define each one so unattended AI coding agents produce verifiable, reviewable, and rollback-safe work by morning.

    Introduction: The Hard Part of Overnight Automation Is the Handoff, Not the Runtime

    When a merge request is still open, CI is backed up in the queue, and review comments can arrive at any moment, a natural thought comes up: can an AI coding agent watch all of this for us overnight?

    Reduce the requirement to a single sentence—“check the merge requests every 15 minutes, fix failing pipelines, handle new review comments”—and you can get two very different outcomes the next morning. In one, the mechanical work really is cleaned up. In the other, the repository has a scattering of unrelated commits, tests have been bypassed, and a failure path is hidden behind a well-worded summary.

    The root cause is not model capability. It is the handoff. For unattended overnight work, the question an engineering team actually has to answer is: which part of the decision-making authority am I handing over, and what constraint does the system add with each step?

    The common agent loop patterns in the industry can be abstracted into four types: turn-driven, goal-driven, time-driven, and proactive. The engineering actions they correspond to are checking, stopping, waiting, and authority boundaries. The sections below treat these four patterns as four handoff points and expand on them one layer at a time.

    Handoff Point 1: Hand Over “Checking” First, and Write Acceptance Criteria as a Reusable Asset

    Most people’s first instinct with automation is “let it keep working.” That step is usually taken too early. A safer starting point is to solidify the verification actions that people normally perform by hand.

    Take a frontend change as an example. An all-green pipeline is usually not enough. A human would additionally do things like: open the page and click the key buttons to confirm the state transitions are correct; check that API responses match the local data; capture screenshots as evidence; scan the console for new errors; and confirm that first render and interactions have not degraded noticeably in performance.

    These actions are fragmented, but they determine whether the tool has “actually verified” the change or merely “feels usable” after editing.

    This is where the turn-driven pattern earns its value: each instruction submission itself triggers a small loop, in which the tool reads code, edits code, runs checks, and then decides whether to continue. The weakness is that this checking is ad hoc and inconsistent, with no unified standard.

    So the first step is not to rush into setting goals or starting a long loop, but to write the checks into a documented skill package so that every run invokes the same standard. A sample structure:

    1. Acceptance skill package
    2. ├── Trigger: an unmerged merge request exists / pipeline failure
    3. ├── Required checks
    4. │ ├── Unit tests and static checks all pass
    5. │ ├── Manual verification checklist for critical paths (3–5 items)
    6. │ ├── No new error logs in the console
    7. │ └── Before/after screenshot comparison
    8. ├── Output format: conclusion + evidence + uncovered items
    9. └── Forbidden actions: skipping tests, deleting assertions, commenting out failing cases

    The most important parts here are the “Output format” and “Forbidden actions” sections. The former requires every conclusion to come with evidence; the latter closes off the common shortcuts in advance. Without these two, automation is just a more efficient way to “look done.”

    Handoff Point 2: Define “Done,” and Make Stop Conditions Decidable

    The second handoff point is the easiest to overlook and the easiest to cause incidents. The point of the goal-driven pattern is not to make the tool more persistent, but to give “done” a decidable standard.

    A vague definition of done shows up in three typical forms. First, treating “I made changes” as done. Second, treating “the pipeline no longer reports this error” as done, when the check has actually been bypassed. Third, writing “remaining issues need human confirmation” into the summary and then stopping, leaving the risk for the next day.

    A decidable stop condition should have three characteristics:

    • Observable: conclusions come from objective signals such as command exit codes, test reports, and coverage data, not from natural-language descriptions.
    • Bounded: explicit limits on the maximum number of commits per night, the maximum number of consecutive retries for a failure, and the maximum runtime for a single task.
    • Reversible: each batch of changes can be reverted independently and is not mixed into the same commit as other changes.

    A stop policy declaration you can adapt:

    1. stop_policy:
    2. done_when:
    3. - All required checks pass
    4. - No new unhandled review comments
    5. give_up_when:
    6. - The same failure still cannot be located after 3 consecutive retries
    7. - Test assertions must be modified to pass
    8. - The scope of the change exceeds the declared directories
    9. max_commits_per_night: 5
    10. on_give_up: preserve the current state and write a list of items for human confirmation

    The rule “give up if tests must be modified to pass” matters especially. It fixes the priority between changing tests and changing the implementation, and keeps the tool from taking the path of least resistance.

    Handoff Point 3: Control the Pace With a Time Policy Instead of Spinning at Full Load

    The third handoff point is waiting. The time-driven pattern solves the frequency question: how often to look, and when not to look.

    High-frequency polling looks efficient but brings three kinds of cost. First, API and quota consumption—a lot of idle spinning overnight yields nothing. Second, repeatedly reading the same state fills the context with noise and lowers the quality of judgment. Third, misalignment with the pipeline queue: checks happen before results are produced, so they can only be retried over and over.

    A better approach is to align the polling interval with the rhythm of the external system and add a backoff mechanism:

    1. Initial interval: 15 minutes
    2. No change → double the interval, capped at 60 minutes
    3. State changes (new commit / new comment / pipeline finished) → reset to the initial interval
    4. Two consecutive rounds with nothing to handle → enter a long sleep and wait to be woken by an external event

    Beyond the interval, agree on “quiet hours”: for example, no automatic commits during an overnight release freeze window, only recording observations. The value of overnight automation is clearing mechanical work, not creating new changes during hours when nobody reviews them.

    Handoff Point 4: Define Authority Boundaries—Can It Assign and Close Out Work Itself?

    The fourth handoff point corresponds to the proactive pattern and is the highest-risk layer: whether the tool can decide task priority on its own, dispatch subtasks, and do the final close-out on results.

    Permissions need to be tiered explicitly rather than covered by a blanket “allowed to act autonomously”:

    Tier Allowed scope Human confirmation required afterward
    L1 Read-only inspection, report generation No
    L2 Fixing deterministic failures (missing dependencies, formatting issues) Spot check
    L3 Changing business logic, responding to review comments Yes
    L4 Merge, release, rollback, deleting branches Forbidden

    The place where the proactive pattern most often goes wrong is “self close-out”: the tool decides the task is done, writes its own summary, and ends the loop. Without external validation, the wording quality of the summary has nothing to do with the quality of the actual result.

    So close-out authority should stay on the system side: the pipeline decides pass or fail, branch protection rules block unauthorized merges, and log services plus monitoring alerts preserve the full execution trail. The tool is responsible only for making progress and recording it, not for declaring victory.

    Suggested Rollout Order

    The four handoff points do not have to be done all at once. A gradual approach in this order is recommended:

    1. Solidify the checks first: enable read-only permissions only, get the acceptance skill package working, and observe the quality of the reports produced over one night.
    2. Add stop conditions: set commit limits and give-up conditions, and verify that it stops correctly on hard problems.
    3. Then tune the time policy: adjust intervals and backoff parameters based on actual pipeline durations.
    4. Only then consider autonomous dispatch: with branch protection, code review, and audit logging in place, gradually open up L2 and L3 permissions.

    Conclusion

    Having an AI coding agent stand watch all night is essentially a transfer of authority, not an extension of runtime. Every layer of autonomy you open up must be matched with a clearer engineering boundary: reusable check standards, decidable stop conditions, a waiting strategy aligned with the external rhythm, and an explicitly tiered authority list.

    Get these four right, and what you see the next morning is no longer a nicely worded summary, but a work record with evidence that can be reviewed and rolled back.