Skip to main content
A run executes an agent on a task. The agent provides the model, skills, guardrails, and tools; the task describes what to do and which resources to work on. The agent runs in a sandbox. Your code receives a Run object for following progress, sending messages, and retrieving results.

Start a run

Retrieve or assemble an agent, then pass a task to agent.run():
The call returns once the run has started. The agent continues working independently, including if your script exits or disconnects. Each call starts a separate run. Use run.id to identify it:

Define the task

A task contains instructions and the resources the agent should work on. The same task can include targets and vulnerabilities. For example, verification instructions can ask an agent to retest a vulnerability against a specific approved target. Task instructions apply to that run. Use skills for procedures and knowledge you want to reuse across runs, and guardrails for constraints on the agent’s behavior.

Work on a vulnerability

Retrieve the vulnerability and include it in the task. This example asks the pre-built remediation-agent to prepare a fix:
You can use the same pattern in a webhook handler. When a vulnerability is assigned to your registered agent, retrieve both and start a run with the requested work. See Assigning to your own agents for connecting this to assignment events.

Follow progress

The Run object is an async iterable. Iterate over it to receive events as the agent works:
Events describe activity during the run, such as progress, tool use, and discovered vulnerabilities. If you only need the final results, wait for completion:
run.wait() resolves when the run completes. If the run fails, it throws an error with the failure details. If the run is stopped, it throws an error indicating that the run was stopped. Vulnerabilities and evidence already saved remain available even if the run fails or stops.

Read vulnerabilities and evidence

Use the run’s resource methods to retrieve vulnerabilities and evidence associated with it:
What a run produces depends on its task. An offensive run may discover vulnerabilities, while a remediation run may prepare a pull request or recommend an infrastructure change. See Vulnerabilities and Evidence for querying and working with these resources.

Adjust or pause the work

Send a message to an active run when you need to provide context or change its focus:
You can also stop a run and resume it later. See Steering and Stopping and resuming for these controls.