What would make an overnight agent useful?
By Flavio
Updated
Tagged: AI
An overnight coding agent needs a question worth answering. Start with the decision its result will help you make, and keep the morning review manageable.
Before leaving an agent running overnight, write down the decision you want to make in the morning. If you can’t name it, the task isn’t ready to hand off.
An agent can stay busy for hours chasing side questions and writing a pile of code. When you open your laptop the next day, you can still be no closer to finishing your project.
I already wrote about which tasks I let agents do unattended. Here I want to back up one step and look at how to pick a job worth starting in the first place.
Start with something you’re putting off
Say you have a search feature that feels sluggish. You’ve been thinking about replacing its database query, except you haven’t measured where the time goes.
That’s a much better overnight job than telling an agent to “improve search.” Have it spin up generated data and benchmark the current query against a proposed index, so by morning you know if the index is worth adding.
Even if the index barely moves the needle, you still get a clear answer. You can drop that idea and look at another part of the request instead.
Make sure the agent saves the exact commands it ran and the settings it used to generate the dataset. Without those, you’re left with a result you can’t reproduce.
The numbers in that diagram are just an example. What matters is ending up with enough evidence to accept that one change or drop it.
Some long jobs need no agent
If you already know the exact checks to run, a plain script or CI job is usually a better fit.
You don’t need a model waking up every night just to figure out how to run your test suite again. A scheduler can run the tests and save the logs, then notify you when something breaks.
An agent earns its keep when the next step depends on what turns up. Once a test fails, it can inspect the error and trace the code behind it to put together an explanation with evidence. Keep that investigation separate from permission to deploy a fix, and split the scheduled run from the agent’s work like this:
This also changes how I think about running a swarm of overnight agents. Multiple workers make sense when you have genuinely separate questions to investigate. Launching extra workers just because your dashboard lets you only leaves you with more output to read in the morning and no clearer answers. The same thing happens with all the chats they leave behind, which I wrote about in Too many conversations with coding agents.
Design tomorrow’s reading
Think about waking up to six big changes that might even depend on each other. Before you can decide whether to use any of them, you have to spend your morning reviewing all six and piecing together what happened overnight.
Compare that to one short report on your search question. It shows the comparison, notes what wasn’t checked, and points to the files you need to repeat it. A proposed patch can sit right beside that evidence until you’ve checked the numbers.
You also need a clear stopping rule. If an investigation gets stuck on a missing credential or an unavailable dependency, the agent should quit and write down what blocked it instead of burning hours on the same dead end.
Write the assignment before starting
Put the question in a file before you kick anything off, so you have a target to compare against in the morning. For the search example, write a brief like this:
Investigate whether an index could reduce the search query's latency.
Use only the disposable local test database and generated records.
Do not change the application, connect to production, or deploy anything.
Record the database version, schema, record count and generation seed.
Run the original query and the indexed version against the same data.
Keep the query text, query plans and timings for each run.
Explain which results would change the decision and which remain uncertain.
Finish with a report containing:
- the decision these measurements support
- commands and results needed to reproduce the comparison
- what you could not check
- the next action for me, including any unanswered product question
If a required credential, dependency or decision is missing, report that
blocker and stop. Do not replace a measurement with an invented result.
In this first run, the application files stay untouched. Temporary database objects belong in the disposable database, and the report goes in a separate output folder you pick ahead of time. Only give the agent access to that test environment.
Don’t rely on a sentence in the brief to enforce a time or spending limit. Set those in the runner or service that starts the task. Do a short disposable run while you’re still at your desk to test the stop behavior, and verify that stopping the agent also stops any test processes it started.
In the morning, read the report alongside the original brief and re-run one measurement yourself before trusting the conclusion. If raw timings are missing, the dataset changed, or a config setting shifted without explanation, the comparison still needs work.
Leaving a question unanswered is allowed
Some investigations run straight into a product decision.
Maybe search is slow because it includes archived records. Excluding them speeds things up, except users might still need those results. When an agent hits a trade-off like that, its job is to lay out the options and stop.
Keep the permissions tight and point the run at a disposable local dataset, never production.
For your first run, pick a question you’ve been putting off because gathering the evidence takes time, and decide how you’ll check the answer before you start. You’ll know right away tomorrow morning whether the report saved you the digging.
Want me to talk about your product? You can sponsor this site.
Related posts about ai: