New Tool Radar

AI Agents & Automation

How to Define What an Agent Stop Button Does, Graceful Stop Versus Kill

Define what an agent stop button does, graceful stop versus kill, before anyone presses it.

Schematic with three steps: Decide graceful stop, kill, or both; Write what happens to a write in; Test both stops on a run with.

A stop button that means two different things to two different people will be pressed wrong at the worst moment. Define it before anyone needs it: a graceful stop lets the current step finish, saves the run’s state, and ends cleanly, while a kill stops everything immediately, wherever it is, and leaves the run to be cleaned up afterwards. LangGraph’s checkpointing makes the graceful version possible, because the graph state is saved and the run can resume later; a kill gives that up for speed. Write down which one your button does, what happens to a write in progress, and what the run looks like afterwards, and put that definition where the person pressing the button can read it.

What you need

  • A run that can be stopped mid-way, with its steps and writes known
  • A decision: graceful stop, kill, or both, with separate buttons
  • A written definition of what each stop does to a write in progress

Step 1: Decide graceful stop, kill, or both

Choose whether the button stops gracefully, letting the current step finish and saving state, or kills immediately, or whether you offer both as separate buttons. One button that sometimes does each is not a definition.

Step 2: Write what happens to a write in progress

For each stop type, write down what happens if a write is running when the button is pressed: the graceful stop finishes it or rolls it back, the kill leaves it half-done. A definition that skips this question will be answered by an accident.

Step 3: Test both stops on a run with a write in progress

Start a test run, press each stop type while a write is in progress, and confirm the run ends the way the definition says, with the state saved or the cleanup noted. If it does not, the definition is not what the code does.

Worked example: synthetic stop button check

The table below is a synthetic example. It shows the expected result of the stop definitions; no run was stopped.

Stop type Current step State after
Graceful stop Finishes, then stops Saved, resumable
Kill Stops at once Needs cleanup
Definition matches behaviour Yes Pass
Both tested with a write running Yes Pass

Expected result (UNTESTED). the graceful stop finishes the step and saves state, the kill stops at once and needs cleanup, and both behave as defined. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A graceful stop still takes time: a step that hangs will delay the stop.
  • A kill can leave a half-written record, so pair it with a cleanup check.
  • Two buttons need two labels, or the wrong one will be pressed under pressure.
  • A stop definition that nobody can find is the same as no definition.

Sources

See all