Cursor Cloud Agent Delegation
What It Does
Describes the lifecycle of delegating work to a Cursor Cloud Agent through the
yellow-cursor CLI, and the JSON contract that CLI exposes on every invocation.
This is a host-neutral reference: it names no host-specific mechanism (no slash
commands, no host environment variables, no host-specific tool-call syntax) so
the same description holds for any integration built on top of the CLI.
Two entities matter:
- Agent — a persistent, addressable unit of work against one repository.
Created lazily: nothing happens server-side until the first message is sent to
it.
- Run — one dispatched execution created by sending a message (the initial
delegation prompt, or a later follow-up). A run carries its own status, target
branch, and pull request, if any. An agent can accumulate multiple runs over
its lifetime.
When to Use
Use this reference when building or reasoning about any surface that delegates
work to a Cursor Cloud Agent through the CLI — deciding what to show a user
before a billable launch, how to interpret the CLI's JSON output, or how to
recover from an ambiguous or failed call.
Usage
Lifecycle
- Setup — resolve credentials (an API key or a stored login) and the SDK
runtime before attempting anything else.
- Delegate — validate the plan with a zero-network dry run, show it to the
person authorizing the spend, get explicit confirmation, then launch for
real. Delegation always costs money once confirmed; nothing here should
launch without that confirmation step.
- Follow-up — continue an existing agent's conversation with a new prompt.
Also billable, also requires confirmation before sending.
- Status — poll an agent (and optionally one of its runs). Always
re-fetches live rather than trusting cached state, and can reconcile a local
record against what the server actually reports.
- Cancel — stop a specific run. Re-checks the run's state immediately
before acting; cancelling an already-finished run is reported as a successful
no-op, not an error.
- Archive / unarchive — lifecycle housekeeping, not deletion. Both are
idempotent: archiving an already-archived agent (or unarchiving one that
isn't archived) succeeds without a server call.
- Artifacts / usage — read-only introspection into what a run produced and
what it cost. Both may be unsupported depending on SDK/account capability —
that is a permanent condition, not something worth retrying.
Safety rules
- No delete. Nothing in this surface can delete an agent, even though the
underlying SDK exposes a delete operation. Archiving is as destructive as this
gets.
- Confirm before billable action. Delegating and following up both spend
money. Never send either without the operator explicitly confirming a plan
that was shown to them first.
- Idempotency keys are reused, not regenerated. Every delegate/follow-up
call is tagged with an idempotency key — supplied by the caller, or generated
once if not. That exact key must be reused for every retry of the same
attempt. Minting a new key on retry defeats the point: it lets a
genuinely-failed-then-retried call look like two separate launches to the
server.
- Ambiguous outcomes are not failures to retry blindly. A network failure
that happens after a message has actually been dispatched cannot tell you
whether the run was created. That case is reported distinctly from an ordinary
network failure specifically so a caller does not treat it as safe to retry.
The correct response is to look up the true state (by the known agent id, or
by the idempotency key if the id isn't known yet) before deciding what to do
next — never re-send automatically.
- No nested delegation. An agent already running inside a remote-delegated
context must refuse to delegate or follow up again — that guard exists to
prevent runaway chains of paid launches.
- Concurrency is capped per repository, checked before every new launch,
with a caller-adjustable limit.
JSON contract essentials
Every invocation of the CLI prints exactly one JSON object to stdout and nothing
else (diagnostics go to stderr). The object always has an ok boolean:
ok:true responses share {ok:true, operation:<name>, ...} plus
operation-specific fields.
ok:false responses share
{ok:false, operation:<name>, error:{code, message, retryable, recoveryAction, requestId?}}.
Every error names a stable code, whether it's worth retrying (retryable),
and what to do about it (recoveryAction) — surface recoveryAction to the
operator rather than inventing your own remediation text.
- Delegating and following up always echo an
idempotencyKey at the top level,
on success and on every failure path (including a plain usage error) —
capture it every time, not just on success, since a failed call is exactly
when you need it for a correct retry.
Never treat the absence of a field as a value — a missing targetBranch or
pullRequestUrl means Cursor hasn't created one yet, not that the launch
failed.
1---2name: cursor-delegation3description: Host-neutral reference for the Cursor Cloud Agent delegation lifecycle, the yellow-cursor CLI's JSON contract, and its safety/idempotency rules. Use when building or reasoning about a surface that delegates work to a Cursor Cloud Agent through the CLI.4---56# Cursor Cloud Agent Delegation78## What It Does910Describes the lifecycle of delegating work to a Cursor Cloud Agent through the11yellow-cursor CLI, and the JSON contract that CLI exposes on every invocation.12This is a host-neutral reference: it names no host-specific mechanism (no slash13commands, no host environment variables, no host-specific tool-call syntax) so14the same description holds for any integration built on top of the CLI.1516Two entities matter:1718- **Agent** — a persistent, addressable unit of work against one repository.19 Created lazily: nothing happens server-side until the first message is sent to20 it.21- **Run** — one dispatched execution created by sending a message (the initial22 delegation prompt, or a later follow-up). A run carries its own status, target23 branch, and pull request, if any. An agent can accumulate multiple runs over24 its lifetime.2526## When to Use2728Use this reference when building or reasoning about any surface that delegates29work to a Cursor Cloud Agent through the CLI — deciding what to show a user30before a billable launch, how to interpret the CLI's JSON output, or how to31recover from an ambiguous or failed call.3233## Usage3435### Lifecycle36371. **Setup** — resolve credentials (an API key or a stored login) and the SDK38 runtime before attempting anything else.392. **Delegate** — validate the plan with a zero-network dry run, show it to the40 person authorizing the spend, get explicit confirmation, then launch for41 real. Delegation always costs money once confirmed; nothing here should42 launch without that confirmation step.433. **Follow-up** — continue an existing agent's conversation with a new prompt.44 Also billable, also requires confirmation before sending.454. **Status** — poll an agent (and optionally one of its runs). Always46 re-fetches live rather than trusting cached state, and can reconcile a local47 record against what the server actually reports.485. **Cancel** — stop a specific run. Re-checks the run's state immediately49 before acting; cancelling an already-finished run is reported as a successful50 no-op, not an error.516. **Archive / unarchive** — lifecycle housekeeping, not deletion. Both are52 idempotent: archiving an already-archived agent (or unarchiving one that53 isn't archived) succeeds without a server call.547. **Artifacts / usage** — read-only introspection into what a run produced and55 what it cost. Both may be unsupported depending on SDK/account capability —56 that is a permanent condition, not something worth retrying.5758### Safety rules5960- **No delete.** Nothing in this surface can delete an agent, even though the61 underlying SDK exposes a delete operation. Archiving is as destructive as this62 gets.63- **Confirm before billable action.** Delegating and following up both spend64 money. Never send either without the operator explicitly confirming a plan65 that was shown to them first.66- **Idempotency keys are reused, not regenerated.** Every delegate/follow-up67 call is tagged with an idempotency key — supplied by the caller, or generated68 once if not. That exact key must be reused for every retry of the _same_69 attempt. Minting a new key on retry defeats the point: it lets a70 genuinely-failed-then-retried call look like two separate launches to the71 server.72- **Ambiguous outcomes are not failures to retry blindly.** A network failure73 that happens _after_ a message has actually been dispatched cannot tell you74 whether the run was created. That case is reported distinctly from an ordinary75 network failure specifically so a caller does not treat it as safe to retry.76 The correct response is to look up the true state (by the known agent id, or77 by the idempotency key if the id isn't known yet) before deciding what to do78 next — never re-send automatically.79- **No nested delegation.** An agent already running inside a remote-delegated80 context must refuse to delegate or follow up again — that guard exists to81 prevent runaway chains of paid launches.82- **Concurrency is capped per repository**, checked before every new launch,83 with a caller-adjustable limit.8485### JSON contract essentials8687Every invocation of the CLI prints exactly one JSON object to stdout and nothing88else (diagnostics go to stderr). The object always has an `ok` boolean:8990- `ok:true` responses share `{ok:true, operation:<name>, ...}` plus91 operation-specific fields.92- `ok:false` responses share93 `{ok:false, operation:<name>, error:{code, message, retryable, recoveryAction, requestId?}}`.94 Every error names a stable `code`, whether it's worth retrying (`retryable`),95 and what to do about it (`recoveryAction`) — surface `recoveryAction` to the96 operator rather than inventing your own remediation text.97- Delegating and following up always echo an `idempotencyKey` at the top level,98 on success _and_ on every failure path (including a plain usage error) —99 capture it every time, not just on success, since a failed call is exactly100 when you need it for a correct retry.101102Never treat the absence of a field as a value — a missing `targetBranch` or103`pullRequestUrl` means Cursor hasn't created one yet, not that the launch104failed.