$run = Clutch::run($runId)->authorizeFor($user);
$run->cancel(reason: 'The request is no longer needed.');
Cancellation is cooperative. The request is recorded immediately, the active driver is signalled, and no new model step or tool starts after that. A tool already running may finish, unless it supports interruption. The package does not pretend otherwise.
Long running tools can cooperate:
public function handle(Request $request): string
{
foreach ($this->pages() as $page) {
if (RunContext::current()?->isCancelled()) {
break;
}
$this->analyze($page);
}
}