Skip to main content

How would you design a harness for an agent that has to work on one task for several hours?

Agents and tools · Pro 2

Short answer

Keep state outside the context window. An initializer writes a feature list and progress file; each session does one item, runs the checks, commits to git and updates the progress file. Reset or compact context between sessions, checkpoint so it can resume after a crash, and set time and cost budgets with clear points to ask a person.

Deeper answer

A long run fails in predictable ways: the context fills up and the agent loses the goal, it tries to do everything at once, it marks work done that does not work, or it crashes and starts over.

A common answer is a planner, generator and evaluator split. A planner or initializer turns the goal into a list of small features, for example as JSON where each item records whether it passes yet, plus a progress file. Each working session reads the progress file and git log, picks one unfinished feature, builds it, and runs tests or an evaluator agent before marking it done. It then commits and writes a short note for the next session.

Between sessions you either compact the context (summarise and continue) or reset it (start fresh and rebuild from files on disk). A reset works well only if the state on disk is complete. Checkpoints or durable execution let the run resume after a crash instead of starting again. Time and cost budgets cap the run, and the harness should stop and ask a person when checks keep failing, the budget is near its end or the next step is risky.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Harnesses for long-running agents

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.