> ## Documentation Index
> Fetch the complete documentation index at: https://docs.restate.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Steering and interruption

> Send new input to a running agent, or stop it with a summary.

While an agent runs, your application can send it new input or stop it.

Name a steering signal and an interrupt signal on the run. Shared handlers then send [signals](https://docs.restate.dev/develop/ts/external-events.md) to the running invocation while the exclusive handler holds the object's lock:

```typescript {"CODE_LOAD::harness/src/steering.ts#steering"}  theme={null}
export const supportSession = restate.object({
  name: "SupportSession",
  handlers: {
    *chat(message: string) {
      restate.state().set("active", {invocationId: restate.handlerRequest().id});
      try {
        const result = yield* support.run(message, {
          conversation: new Conversation(),
          steeringSignal: "steering",
          interruptSignal: "interrupt",
        });
        if (result.status !== "completed") return result.output ?? result.reason;
        return result.output;
      } finally {
        restate.state().clear("active");
      }
    },
    *steer(message: string) {
      return yield* signalActiveTurn("steering", message);
    },
    *interrupt(reason: string) {
      return yield* signalActiveTurn("interrupt", reason);
    },
  },
  options: {
    state: {preload: ["conversation/meta", "conversation/summary", "active"]},
    handlers: {steer: {shared: true}, interrupt: {shared: true}},
  },
});

function* signalActiveTurn(name: string, value: string): restate.Operation<boolean> {
  const active = yield* restate.sharedState().get<ActiveTurn>("active");
  if (!active) return false;
  restate.invocation(active.invocationId).signal(name).resolve(value);
  return true;
}
```

* **Steering:** The run records the message in its history as a user message, with the steering text in a JSON note. With a `conversation`, the run saves the message as described in [Saving progress](https://docs.restate.dev/harness/sessions.md#saving-progress). The model receives it in the next step, after the current tool calls finish. A running `run_program` call doesn't delay it: the program continues in the background, and the model receives its result in a later step. Steering doesn't undo tool calls that already started. A message that the run accepts during a model call discards that call's response, and the run asks the model again in a new step, which counts toward `maxSteps`.
* **Interruption:** The run cancels unfinished tool calls and the child invocations of `handlerTool`, `serviceTool`, and `awaitChild`, and returns `{status: "interrupted", reason, output}`, with a summary in `output`, unless the agent sets `finalize: false`.

The `chat` handler stores its invocation ID in state, so `steer` and `interrupt` can read which invocation to signal. It clears the ID in `finally`, so a failed run leaves no stale ID behind.

Interrupting a run is different from [cancelling the invocation](https://docs.restate.dev/services/invocation/managing-invocations.md#cancel): cancellation fails the handler instead of returning a result. See [Error handling](https://docs.restate.dev/harness/error-handling.md#cancellation).

To check or redact steering messages before the run uses them, add a `beforeSteering` [guardrail](https://docs.restate.dev/harness/guardrails.md).
To control the run from your own code instead of signals, pass `controls: {steering, interrupt}` to `run`. `steering` is a function that returns a future for the next message, and `interrupt` is a future that resolves to the reason.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.