# cancel_job

Source: https://modulify.ai/docs/mcp/chat/cancel-job

Stops a generation that is currently running on a site.

- Title: Cancel a running generation
- Scope: `chat:write`
- Access: Makes changes

Work the agent has already written to the site is kept. Leave out `jobId` to cancel whichever generation is running in the chat, which is `main`, the chat every site comes with, unless you pass `chatId`. When none is, the call answers `404` with `There is no generation running in this chat!` when you passed a `chatId`, and with `There is no generation running for this site!` when you did not. Generations running in other chats of the site keep running. The response carries `chatId`, the chat the cancelled generation ran in, even when you passed only a `jobId`.

Stopping a generation parks that chat's message queue, so anything queued in it waits until `resume_queue` releases it. Set `clearSession` to also reset the agent session of that chat, so its next message starts a fresh conversation. On a site with several chats, what the agent already wrote is merged into the site the same way as at the end of a turn. See [Stop a run](https://modulify.ai/docs/build/site-chat#stop-a-run) and [Merging when a turn ends](https://modulify.ai/docs/build/multiple-chats#merging-when-a-turn-ends).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `jobId` | string | No | The generation to cancel. Leave it out for the one running now. |
| `clearSession` | boolean | No | True to also reset the agent session of that chat, so its next message starts a fresh conversation. |
| `chatId` | string | No | The chat whose running generation to cancel when `jobId` is left out: `main` for the chat every site comes with, or the `chatKey` of another chat from `list_chats`. Defaults to `main`. |