Agent (server-side)

stop()

agent.stop() → Promise<{ ok, stopped }>

Asks the platform to end the run in progress. Without one in flight it answers that there was nothing to stop.

one requestno-op when idlesignal is the other way
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

const running = agent.run({ inputs, onStep });
setTimeout(() => agent.stop(), 30_000);
const result = await running;
import threading

threading.Timer(30, agent.stop).start()   # stop() is safe to call from another thread
result = agent.run(inputs=inputs, on_step=on_step)

With nothing running

It answers { ok: true, stopped: false } and makes no request — safe to call from an interface that does not track whether a run is in flight.

stop() and signal are not the same

stop()signal
Tells the platform to stopyesno
Ends your requestwhen the run endsimmediately
The run may keep goingnoyes
Aborting the request does not stop the work

The run continues on the platform, and anything it spends is still spent. Use stop() to end the work and signal to stop waiting — and when you mean both, call stop() first.

The local engine's stop is different

There the loop is in your process, so stop() is immediate and needs no request at all.