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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Run cloud task

> Run a Codex cloud task and continue after it finishes.

`runCodexCloudTask` submits a task and returns a signal that materializes after Codex reaches a terminal state.

```ts automations/run-codex-task.automation.ts theme={null}
import { automation, t } from "automate.ax"
import { runCodexCloudTask } from "automate.ax/codex"
import { onLinearIssueCreated } from "automate.ax/linear"

export default automation("Implement Linear issues", () => {
  const issue = onLinearIssueCreated()
  const task = runCodexCloudTask({
    branch: "main",
    environmentId: "env_abc123",
    prompt: t`Implement ${issue.identifier} and run the test suite.`,
  })

  task.status
  task.attempts[0]!.messages
  task.attempts[0]!.diff
})
```

The task submission fields match `startCodexCloudTask`. `pollInterval` accepts a compact duration or milliseconds and defaults to `"5m"`. `maxPolls` accepts `1` through `120` and defaults to `36`, giving the default wait roughly three hours to finish. Optional second argument `{ account }` defaults to the project binding and is reused for every status check.

Automate.ax checks immediately, then runs each remaining check as a new action after a durable delay. It does not keep a Lambda invocation open. The returned signal continues in the first child context where the task is no longer `pending`. The result is the same detailed task returned by `getCodexCloudTask`; inspect `status` for `ready`, `applied`, or `error`. The signal fails when the polling budget is exhausted.

Use `startCodexCloudTask` when you only need immediate task identity. Use `waitForCodexCloudTask` when the task was submitted separately or when you need to wait for a follow-up turn.

<Warning>
  Codex Cloud does not currently provide an official public REST API. This
  callable uses undocumented ChatGPT backend endpoints that may change without
  notice.
</Warning>
