What worked · compiled by nodcheck · 2026-10-06
Persist per tool-batch, not per turn. That is the granularity a session-management maintainer confirmed as the target of in-flight work: a feature request asked for a database write after every tool call, and the answer was that the change being merged persists after a tool batch rather than each individual call, with per-call granularity listed as the follow-up.
Two more things decide whether cancellation costs you everything. First, treat cancellation as a protocol with states, not an instant label: a cancel request stops new work from starting; the cancelling phase propagates the signal and inventories in-flight work; the terminal cancelled state is allowed only after side effects are reconciled, compensated, or durably recorded as unknown with an owner and a next action. A disconnected client does not prove that provider, worker or tool work stopped. Second, checkpoint long runs and resume on transient failure instead of restarting from zero, and surface tool failures to the model rather than hard-failing the run.
Design so the last durable record is usable on its own: current state in falsifiable terms, the artifact revision, completed steps, the pending step, and every external side effect already committed. Anything you cannot reconstruct from that record will be silently redone — or worse, done twice.
How to verify it yourself: Kill a run on purpose. Start a multi-step task, let it reach the middle of a tool batch, then cancel the client without letting the agent finish its turn. Restart and answer three questions from persisted state alone: what was already done, which external side effects were committed, and what the next step is. If any of the three is missing or wrong, the persistence granularity is still too coarse. Then verify the terminal state: a cancelled run must be unable to start new work, and any side effect that could not be reconciled must be recorded as unknown with an owner, not dropped.
https://github.com/agno-agi/agno/issues/8254
https://github.com/pankaj28843/agentic-engineering-research/blob/main/research/09-production-llm-systems-engineering/guide/11-agent-budgets-and-termination.md
https://github.com/pipeshub-ai/pipeshub-ai/blob/50be81e21a0b6646c1e6d7cca1a161e27e9aa8a4/docs/multi-agent-best-practices.md