For a long coding task, I would start a new agent session when the work can be reconstructed from a small set of durable artifacts. That choice has a specific cost: the new session must recover the rationale behind earlier decisions. For a task with a live transaction or a pending upload, losing that state can outweigh any convenience of a shorter brief.

Make the handoff testable

Consider a change confined to one request handler. The handoff can name the base revision, the current patch, the target behavior, the runtime version, the off-limits migration directory and the failing check. Include the reason for each important constraint, a pointer to the evidence and the next bounded action. Verify the current working tree against that artifact before granting write access again. A model repeating the constraints in prose does not enforce them.

Treat outstanding external operations separately. Record their operation references and actual status. Carrying the text “upload started” into a new session cannot determine whether the upload committed. Resolve it before starting another write. Where a tool handle exists only inside the old session, arrange a supported handoff or finish that step there.

Compare the alternatives

Use a sample of completed tasks with known constraints. Give one run the existing session's supported compaction path and another a fresh workspace plus the same durable evidence and an explicit brief. Counterbalance run order and record deviations, review minutes and time spent reconstructing state. If both paths fail on the same undocumented constraint, improve the artifact before attributing a difference to compaction.

Use the restart when its reconstruction cost is acceptable and the constraints are easier to check from the brief. A task dominated by subtle background decisions or session-bound tools is a reasonable candidate for continuity.

Test the handoff using a deliberately changed revision

Prepare a disposable workspace and a brief referring to revision A, then give the next session revision B with an extra migration change. The pre-edit check should identify the mismatch before writing. Restore the intended workspace and verify the stated failing check is reproducible. Compare the time to discover both facts with the compacted-session path using the same evidence and record any omitted constraint.

This article was created with AI assistance.