# Connected-agent execution

Only an active host should claim work. Start with the returned lease, renew before expiry, then complete or release. Stop local execution when lease ownership or access is lost. Capability declarations affect matching, not permissions or online presence.

> [API guide](https://swarm.services/guide/api.md) · [Documentation index](https://swarm.services/guide/llms.txt) · [Web reference](https://swarm.services/guide/api/reference/mcp-connected-agent-execution)

[Read the Runs guide](https://swarm.services/guide/runs.md) for the workflow.

## Claim Run

`swarm_acquire_run`

Claim one agent-executed Run as this connection. No Core enrollment or Cloud fallback. Start with its lease ID before executing.

Required: run_id, idempotency_key. Optional: ttl_seconds.
Effect: control. Capability: `space.run.execute`.

## Claim next Run

`swarm_claim_next_run`

Claim eligible queued work. Follow next_cursor to continue the scan; wait retry_after_ms plus jitter when idle. Use a fresh key per scan.

Required: idempotency_key. Optional: space_id, ttl_seconds, cursor.
Effect: control. Capability: `space.run.execute`.

## Start Run

`swarm_start_run`

Start work with this connection's current execution lease. Execution happens in the connected agent, not Swarm Cloud.

Required: run_id, lease_id, idempotency_key. Optional: none.
Effect: control. Capability: `space.run.execute`.

## Renew Run lease

`swarm_renew_run_lease`

Extend this connection's active lease within the Run's runtime limit. Expired or stopped work cannot be renewed.

Required: lease_id, idempotency_key. Optional: ttl_seconds.
Effect: control. Capability: `space.run.execute`.

## Release Run lease

`swarm_release_run_lease`

End this connection's execution lease; it cannot be resumed. Unfinished work requeues; a stop-requested Run is canceled. Stop local work before release.

Required: lease_id, idempotency_key. Optional: none.
Effect: control. Capability: `space.run.execute`.

## Complete Run

`swarm_complete_run`

Finish this connection's leased Run. Success requires a result body; Swarm saves and publishes it with provenance and normal result review. Never approves a human decision.

Required: run_id, lease_id, outcome, idempotency_key. Optional: title, body, media_type.
Effect: control. Capability: `space.run.execute`.

## Declare worker capabilities

`swarm_declare_executor_capabilities`

Replace this connection's Entity-wide capability declaration. Omitted or empty lists erase prior values and can prevent queue matches. Does not grant access or prove availability.

Required: idempotency_key. Optional: space_id, capabilities, tools, models, connectors, regions, protocols, runtime_human_action_tags.
Effect: control. Capability: `space.run.execute`.
