# get_job

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

Reads the progress of a site generation and the events it has produced since your last call.

- Title: Read generation progress
- Scope: `chat:read`
- Access: Read only

Pass back the `cursor` from your previous call to receive only the new events. Leave out `jobId` to read the most recent generation in the chat, which is `main`, the chat every site comes with, unless you pass `chatId`, and a chat that has never run one answers with `state` null.

The response carries `chatId`, the chat the generation ran in, even when you passed only a `jobId`. Send any answer to a question the agent asked to that chat.

`running` means keep polling. `stalled` means the agent has sent no heartbeat for over a minute and no server is running the turn any more, and it is not an ending either: keep polling, because the platform resumes or closes a generation that has produced nothing for 15 minutes. `heartbeatAt` is when the agent last sent one, and starts at the time the generation was created. The endings are `succeeded`, `failed` and `cancelled`, and after a failed or canceled generation, or one that ended part way through, anything queued in that chat waits for `resume_queue`, except after a failure with `SC-6002`, described below.

A `succeeded` generation is not always a finished one. `incomplete:true` means the agent stopped part way through the turn, `incompleteReason` says how (`terminal-reason`, `max-output-tokens`, `max-turns`, `max-budget`, `agent-error` or `no-closing-message`) and `incompleteCode` carries the matching error code. The turn was still billed and anything it already changed was kept, so continue the work rather than starting it over.

When it stopped because the AI service hit a usage limit (`incompleteCode` `SC-2001`) or because it used every step it may take in one run (`incompleteReason` `max-turns`, `incompleteCode` `SC-5004`), the platform usually continues it for you. `continuedBy` then carries the `jobId` of the generation that picked the work up, so poll that one and do not send a continue yourself. While `continuing` is `true` that decision is still being made, so keep polling this generation until `continuedBy` appears or `continuing` turns `false`. Calling `cancel_job` on this generation while `continuing` is `true` stops the continue from starting.

A `failed` generation whose `errorCode` is `SC-6001` ran out of AI credits part way through. It was stopped there, anything it already changed was kept, and only what the balance could cover was charged, so the workspace needs a plan or more credits before that work is sent again.

A `failed` generation whose `errorCode` is `SC-6002` was stopped because the AI credits left were set aside for the other chats running in the workspace. Anything it already changed was kept, its chat's queue is not parked, and the work can be sent again once those chats finish. See [Multiple chats](https://modulify.ai/docs/build/multiple-chats#credits).

When the response has `reset:true`, the generation was retried from the start, so discard the events you collected and continue from the new `cursor`. See [When a run fails](https://modulify.ai/docs/build/site-chat#when-a-run-fails).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `jobId` | string | No | The generation id that `send_message` returned. Leave it out for the latest generation. |
| `cursor` | integer | No | The `cursor` from your previous call. Use `0` or leave it out on the first call. |
| `limit` | integer | No | How many events to return, up to 500. Defaults to 200. |
| `chatId` | string | No | The chat whose latest generation to read 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`. |