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

# Send work to an agent

> Hand a task to a coding agent that runs inside a Computer, then watch it work, steer it, and collect the changed files and a summary when it finishes.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Start a turn with one of eight coding agents, follow it live, redirect or stop it, and read the result from the CLI, the API, an SDK or MCP.

## Prerequisites

* A running computer, ideally with your code in `/workspace`.
* For each agent you want to use, either a sign-in to that agent on the computer or a model key saved with `stackshift computers secrets`.
* The StackShift CLI, or a computers key for the API, an SDK or MCP.

## Workflow

**Step 1**

List the agents and see which are signed in: `stackshift computers agent providers my-computer`.

**Step 2**

Sign in once, if the agent uses a subscription: `stackshift computers agent login my-computer --provider claude`. Or save a model key with `stackshift computers secrets set` and pass it with `--secret`.

**Step 3**

Start a turn: `stackshift computers agent prompt my-computer 'Fix the failing tests' --provider claude -f`. The `-f` flag follows the agent as it works.

**Step 4**

Steer or stop it while it runs with `agent steer` and `agent interrupt`.

**Step 5**

When the turn ends, read what it did with `stackshift computers agent result my-computer`.

## What it is

A Computer can run a coding agent for you. You send a task, the agent works on the computer’s files and terminal, and StackShift records every step. You can watch live, add instructions while it works, stop it, and pick up the result afterwards, all without opening a terminal yourself.

Each task is a turn. A turn belongs to a conversation, and you can send another turn to the same conversation to continue where the agent left off.

```bash From the CLI theme={null}
stackshift computers agent login my-computer --provider claude
stackshift computers agent prompt my-computer 'Fix the failing tests' --provider claude -f
stackshift computers agent prompt my-computer 'Match this design' --attach design.png
stackshift computers agent result my-computer --wait
```

## The eight agents

Use `--provider` with one of these names. The default is `claude`. The first time you use an agent, StackShift installs it on the computer.

* `claude` (Claude Code): signs in, or takes an Anthropic model key.
* `codex` (Codex): signs in, or takes an OpenAI model key.
* `gemini` (Gemini CLI): signs in, or takes a Gemini model key.
* `opencode` (OpenCode): signs in, or takes an Anthropic or OpenAI model key.
* `cursor` (Cursor): signs in only. It does not take a model key.
* `copilot` (GitHub Copilot): signs in, or takes an Anthropic or OpenAI model key.
* `amp` (Amp): signs in only. It does not take a model key.
* `qwen` (Qwen Code): signs in, or takes an Anthropic or OpenAI model key.
* `stackshift computers agent providers COMPUTER` (add `--refresh` to check again instead of using the last 30 seconds) shows, for every agent, whether it is installed, which version, whether it is signed in and by which method (`subscription` or `api_key`), and which model keys it accepts.
* `stackshift computers agent models COMPUTER --provider X` lists the models you can pick for that agent. Add `--secret BINDING_ID` to list the models a saved model key can use; the list comes from the key’s provider. Without a key, Codex, Gemini CLI, OpenCode and Cursor list their own models; the others have no list, and the agent uses its own default.

## Sign in an agent

Run `stackshift computers agent login COMPUTER --provider X`. It opens its own terminal tab on the computer and runs the agent’s sign-in there; the tab closes when the sign-in ends. On a desktop Computer, the agent’s sign-in page opens in the browser on that desktop, so you can finish it in the live view. On a coding Computer, which has no desktop, the command prints a link and a code. Open the link on your own device and enter the code.

A sign-in stays inside the computer. It is not copied to your StackShift account. Snapshots and forks of the computer keep it, so a fork can start working straight away. If you delete the computer without a snapshot, the sign-in goes with it.

## Use a model key instead

Save the key with `stackshift computers secrets set`, then pass its binding with `--secret` (CLI) or `secret_binding_ids` (API and SDKs). StackShift adds the key to the agent’s requests on the way out. The key never enters the computer, so the agent and anything it runs cannot read it.

Send a key kind the agent cannot use and the request fails with `invalid_request`. Cursor and Amp sign in with their own accounts only and accept no model key. Setting the agent’s own key variable with `--env KEY=VALUE` also counts as signed in, but a key saved with `computers secrets` is the safe way, because it never enters the computer.

## From the dashboard

Open a Computer and choose the Agent tab beside the terminal tabs. Pick the agent. It shows Signed in, Sign in needed or Installs on first use. Next to the agent picker is the Model key picker. It starts on “Use this computer’s sign-in” and lists the keys saved for this computer that the chosen agent can use. Choose “Add a key…” to save a new one: give it a name, a provider and the key. The key is never shown again and never enters the computer. Cursor and Amp have no key picker, because they sign in with their own accounts. The Model picker starts on “Agent default” and lists the models the chosen agent and key can use. It updates when you change either. If a key is refused, only the agent default is offered. A conversation you continue shows the model it ran with. Type the task, attach files and press Send.

Messages, commands and file edits appear as they happen. Type into the box to steer the agent, or press Stop to end the turn. Choose Run on copies (1 to 3) to run the task on forks, then use Open a copy to look at one or Keep this one to keep it and delete the rest. Turns also show in the Steps tab.

## Start a turn

Every route is under `/api/v1/computers/{id}/agent`. A new turn returns a conversation with status `running`.

List the models for an agent with `GET /agent/models?provider=X`, adding `secret_binding_id` to list what a saved key can use. It returns `models` (each with `id` and `name`) and `source`: `provider` when the key’s provider listed them, `agent` when the agent listed its own, `none` when there is no list. A key its provider refuses returns `invalid_request`. Options on a prompt: `provider`, `model`, `cwd` (where the agent works), `env`, `secret_binding_ids`, `attachments`, and `conversation_id` to continue an earlier conversation. In the CLI these are `--provider`, `--model`, `--cwd`, `--env`, `--secret`, `--attach` and `--resume`.

* The Go, PHP and Ruby SDKs have the same calls: prompt, providers, models (`agentModels` in TypeScript and PHP, `agent_models` in Python and Ruby, `AgentModels` in Go), conversations, events, steer, interrupt, result, fan-outs, turn history, keep, and a helper that uploads a file and returns its path.
* MCP: `computer_agent_prompt` starts a turn. `computer_agent_events`, `computer_agent_steer`, `computer_agent_interrupt`, `computer_agent_conversations`, `computer_agent_providers` and `computer_agent_models` do the rest. They use the same key scopes and approval rules as `computer_exec`.

```bash API theme={null}
curl -X POST https://api.stackshift.cloud/api/v1/computers/$COMPUTER_ID/agent/prompt \
  -H "Authorization: Bearer $STACKSHIFT_COMPUTERS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "codex",
    "prompt": "Fix the failing tests and explain what was wrong",
    "cwd": "/workspace/app"
  }'
```

```typescript SDKs theme={null}
const computer = await stackshift.computers.get(computerId)
const file = await computer.attachAgentFile('./design.png')
const conversation = await computer.promptAgent({
  provider: 'claude',
  prompt: 'Match this design',
  attachments: [file],
})
for await (const event of computer.followAgentEvents(conversation.id)) {
  console.log(event.kind, event.text)
}
const { status, result } = await computer.agentResult(conversation.id, { wait: true })
console.log(result?.last_message, result?.changed_files?.files)
```

```typescript TypeScript theme={null}
const computer = await stackshift.computers.get(computerId)
const file = await computer.attachAgentFile('./design.png')
const conversation = await computer.promptAgent({
  provider: 'claude',
  prompt: 'Match this design',
  attachments: [file],
})
for await (const event of computer.followAgentEvents(conversation.id)) {
  console.log(event.kind, event.text)
}
const { status, result } = await computer.agentResult(conversation.id, { wait: true })
console.log(result?.last_message, result?.changed_files?.files)
```

```python Python theme={null}
conversation = computer.prompt_agent("Fix the failing tests", provider="claude")
for event in computer.follow_agent_events(conversation["id"]):
    print(event["kind"], event.get("text"))
done = computer.agent_result(conversation["id"], wait=True)
print(done["status"], done["result"]["last_message"])
```

## Attach files

Give the agent screenshots, specs or data with `--attach FILE`. Repeat the flag for more files, up to 20. The CLI uploads each file to `/workspace/.stackshift/attachments/` on the computer and adds a short list of the paths to the end of your prompt, so the agent knows where to look.

Over the API, upload the files yourself with the files route, then send their paths in `attachments`. Every path must be a regular file under `/workspace/.stackshift/attachments/`.

## Follow what the agent does

`stackshift computers agent prompt ... -f` and `stackshift computers agent events COMPUTER -f` show events as readable lines; `events` takes `-c CONVERSATION`. `computers watch` and the computer events stream also send an `agent.turn` event when a turn ends. Add `-o json` for the raw events. Over the API, `GET /conversations/{cid}/events` returns a page, and adding `follow=1` with `Accept: text/event-stream` streams them as they happen.

Every event has a number (`seq`), the turn it belongs to and a time. These are the kinds:

* `turn.started`: the turn began, and `prompt` holds the text.
* `installing`: the agent is being installed on the computer for the first time.
* `message`: something the agent said, in `text`.
* `command`: the agent ran a shell command, in `command`.
* `file_edit`: the agent created or changed the file in `path`.
* `tool_call`: the agent used another tool. `tool` names it and `text` is a short summary.
* `error`: something went wrong, described in `text`.
* `agent`, `output` and `stderr`: lines from the agent that do not fit another kind. Raw lines are kept in `data`.
* `turn.ended`: the turn is over. It carries `status`, `exit_code` and the `result`.

## Steer and stop

`stackshift computers agent steer COMPUTER 'Also run the linter'` sends a new instruction into the running turn. `stackshift computers agent interrupt COMPUTER` stops it. Both act on the newest conversation unless you pass `-c CONVERSATION`. An interrupted turn ends with status `interrupted`, and the work done so far stays on the computer.

`agent ls` lists the conversations on a computer. A conversation shows `running` while a turn works and `idle` when the turn finished. The status of a finished turn in a result, a turn record or a copy is `completed`, `failed`, `interrupted`, `needs_input` or `lost` (the computer stopped while the turn ran).

## Collect the result

`stackshift computers agent result COMPUTER` (add `-c CONVERSATION` for an older one) prints the last turn’s summary: how long it took, the exit code, what the agent said last (`last_message`) and a changed files summary. When the computer’s folder is a Git repository, the summary gives how many files changed, the lines added and removed, and a short diff stat.

Add `--wait` to wait for a running turn to finish. Add `-o json` when a script or a CI job reads the result. Over the API, `GET /conversations/{cid}/result` returns `{conversation_id, provider, turn, status, result}`, where `status` is `completed`, `failed`, `interrupted`, `needs_input` or `lost`. It answers `409` while the turn is running unless you add `?wait=1`, which waits up to 25 seconds.

## Turn history

`GET /computers/{id}/agent/turns` lists every turn on the computer, newest first, with its prompt, status, result and fan-out. It includes copies still waiting to start, takes `limit` (1 to 200, default 50), and works while the computer is paused. In the SDKs it is `agentTurns` (JavaScript) and `agent_turns` (Python). Each turn that ends also appears in the Steps tab.

## Run the same task on several copies

Try one task several ways and keep the best. `--forks N` (1 to 3) forks the computer live and starts the same prompt on every copy. `--prompts FILE` reads one prompt per non-empty line, up to 3, and gives each copy its own. Model keys named in the request are copied onto each fork, so every copy can use them without seeing them.

`stackshift computers agent fanout COMPUTER` lists your fan-outs. Add the fan-out id to see each copy’s name, prompt, status and result. When you have a winner, `stackshift computers agent keep COMPUTER FANOUT FORK` keeps that copy and deletes the other copies. Your original computer stays.

A copy starts as `starting`, then goes to `running`, and ends as `completed`, `failed`, `interrupted`, `needs_input` or `lost`. Over the API this is `POST /agent/prompt` with `forks` or `prompts`, `GET /agent/fanouts`, `GET /agent/fanouts/{id}` and `POST /agent/fanouts/{id}/keep` with `{"computer_id": "..."}`. You cannot combine `forks` with `conversation_id`.

```bash Three copies, keep one theme={null}
stackshift computers agent prompt my-computer 'Fix the login bug' --forks 3
stackshift computers agent fanout my-computer
stackshift computers agent fanout my-computer FANOUT_ID
stackshift computers agent keep my-computer FANOUT_ID FORK_COMPUTER_ID
```

```bash A different prompt for each copy theme={null}
stackshift computers agent prompt my-computer --prompts approaches.txt --provider claude
```

## The computer stays awake

While a turn runs, StackShift keeps the computer awake, so the idle policy does not pause it halfway through the work. The hold ends when the turn ends. If you close your laptop, the agent keeps going and you can read the result later.

## Notifications and webhooks

When a turn ends as `completed`, `failed` or `needs_input`, StackShift sends a notification. Interrupted turns do not notify you, because you caused them. A turn lost because the computer stopped is reported as `failed`.

Subscribe a webhook endpoint to the `computer.agent.turn` event to start the next step of a pipeline. The `status` is `completed`, `failed` or `needs_input`. Stopped turns send nothing. Every Computer webhook has this body: an `id`, the `type`, a `timestamp` and a `data` object. Each delivery is signed with the same `webhook-id`, `webhook-timestamp` and `webhook-signature` headers as the other Computer webhooks, so verify it the same way. `result` can be null. The notification is called “Coding agent finished”. It shows in the app by default, and you can switch on email and Slack in notification settings.

```json A computer.agent.turn payload theme={null}
{
  "id": "3f1c8a52-7d0e-4b69-a2c4-5e8f1b9d6a70",
  "type": "computer.agent.turn",
  "timestamp": "2026-11-12T20:26:40.868110Z",
  "data": {
    "computer": {
      "id": "0f6c1d4e-5b2a-4c8e-9f3a-2d7b8e1c4a90",
      "name": "build-box",
      "project_id": "b21e6c0a-94d3-4f7b-8a15-c3d9e7f02a48"
    },
    "computer_id": "0f6c1d4e-5b2a-4c8e-9f3a-2d7b8e1c4a90",
    "computer_name": "build-box",
    "conversation_id": "conv_7a2e9c41",
    "turn": 2,
    "provider": "claude",
    "status": "completed",
    "result": {
      "duration_ms": 90000,
      "exit_code": 0,
      "last_message": "All tests pass. The date parser ignored the time zone.",
      "changed_files": { "files": 2, "insertions": 48, "deletions": 11, "stat": "src/date.ts | 40 ++++\n..." }
    }
  }
}
```

## Safety and cost

* The computer is the boundary. The agent runs with its own permission prompts skipped, so it can change anything on that computer without asking. Give it a computer you are happy for it to change, and use a snapshot to go back.
* The computer’s internet policy still applies. Under `allowlist` or `none`, the agent can reach only what the policy allows, which also limits what it can send out.
* StackShift bills computer running time only. The model costs are paid by your own key or your own subscription with the agent’s maker.
* Model keys stay outside the computer. Agent sign-ins stay inside it, and go with its snapshots and forks.

## Expected result

> [!TIP]
>
> The agent works inside the computer, you see each message, command and file change as it happens, and when it stops you get a summary, the exit code and the list of files it changed.

## Common failures

> [!WARNING]
>
> * The turn ends at once with status `needs_input`. The agent is not signed in on this computer and the request had no model key. Run the `agent login` command in the message, or pass a key.
> * `400 invalid_request` with “cursor signs in with its own account; model keys do not apply”. Cursor and Amp sign in only; use `agent login` for them.
> * `400 invalid_request` with “provider must be one of claude, codex, gemini, opencode, cursor, copilot, amp, qwen”. Use one of those names.
> * The turn failed with a message naming `npm`, `uv` or `curl`. The agent installs itself the first time you use it, and the computer needs that tool. Install it, or use a template that has it.
> * `409` from `agent result`. The turn is still running. Add `--wait` (or `?wait=1`) to wait up to 25 seconds, or follow the events.
> * `attachments` rejected. Each path must be a regular file under `/workspace/.stackshift/attachments/`, up to 20 files. Use `--attach` or the SDK `attach` helper, which put files in the right place.
> * A fork request answers `limit_exceeded`. You can run the same task on at most 3 copies, and your plan must be able to run that many computers.

## Related guides

> [card] [Computers: a cloud computer for any agent](https://docs.stackshift.cloud/computers/overview.md)
>
> A Computer is a full Linux machine, with or without a desktop, that an agent or a person can create, drive, pause, fork and delete from anywhere.

> [card] [Pause, snapshot and fork](https://docs.stackshift.cloud/computers/pause-snapshot-and-fork.md)
>
> Pause a computer to stop paying for running time, snapshot it to keep a copy, and fork it up to 20 times to try many things from one starting point.

> [card] [Computers keys and limits](https://docs.stackshift.cloud/computers/keys-and-limits.md)
>
> A computers key lets an agent or tool drive computers and nothing else. Set how many it may run, how large, from which templates and how much it may spend.

> [card] [Computers CLI reference](https://docs.stackshift.cloud/computers/cli.md)
>
> Every `stackshift computers` command: open a shell, create, list, run commands, move files, publish ports, fork, pause, snapshot and manage keys.

> [card] [Computers REST API](https://docs.stackshift.cloud/computers/rest-api.md)
>
> Every computer action is an endpoint under /api/v1/computers, with idempotent mutations, a typed error format, live sessions and an event stream.

> [card] [Computers MCP tools](https://docs.stackshift.cloud/computers/mcp-tools.md)
>
> One MCP address gives any MCP client 18 tools to create computers, see and use their screens, run commands, fork, pause and ask you first.


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