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

# Execution on workers

> How the agent's actions reach real infrastructure: choosing and pinning a worker, shell commands in a per-session sandbox, one-off connector runs, browser sessions, and how output travels back across API replicas

The agent never runs security tooling on the core API host. Everything that touches a target — a shell command, a scanner, a browser — runs on a [worker](https://docs.oasm.io/architecture/worker-runtime.md), and the result travels back over the worker's gRPC connection. This page explains the three execution paths and what they share.

```mermaid theme={null}
sequenceDiagram
    participant A as Agent run (API replica A)
    participant R as Redis
    participant B as API replica B<br/>(holds worker stream)
    participant W as Worker
    participant S as Sandbox / connector / browser

    A->>R: subscribe remote-execute:results:<session>
    A->>B: push command (worker's subscribe stream)
    B->>W: RemoteExecuteSubscribe
    W->>S: run
    S-->>W: stdout, stderr, image, exit
    W->>B: RemoteExecuteResult
    B->>R: publish to the session channel
    R-->>A: events until exit, error or timeout
```

## Choosing a worker

A conversation sticks to one worker, so files, tools and browser sessions from earlier commands are still there for later ones. The worker is chosen in this order:

1. the worker the conversation is **pinned** to — the user can pick one in the composer,
2. a connected worker of the **workspace**,
3. a **global** worker that runs the agent sandbox.

The pin is written only after a command was successfully handed to that worker, and a pin that is no longer in scope is cleared. Which workers may serve which workspace follows the worker rules: a workspace worker serves its own workspace, a global worker serves agents of any workspace only when it runs with the sandbox enabled, and provider workers never serve agents. See [Worker and connector runtime](https://docs.oasm.io/architecture/worker-runtime.md#the-agent-sandbox).

## Shell commands

`execute_remote_command` runs one command and waits for it. It needs `worker.write`, is Agent-mode only, and gates itself on the raw command text, so the [deny list, rules, scope gate and approval](https://docs.oasm.io/architecture/ai-agent/safety.md) all see exactly what will run.

* On a sandboxed worker, each AI session gets its **own container**: read-only root filesystem, all capabilities dropped, memory and process limits, the worker's tools mounted read-only, and none of the worker's environment, token or Docker socket.
* Output streams to the console **live** as the command runs. stdout and stderr are each capped at 10 MiB.
* stdout is stored for one hour under a run id, so the model can page through long output with `read_tool_output`, and so evidence quotes in [finding proposals](https://docs.oasm.io/architecture/ai-agent/safety.md#resisting-prompt-injection) can be checked against it.

## Connector runs

`run_tool_connector` runs one [connector](https://docs.oasm.io/connectors/overview.md) against one target on the conversation's worker, without creating a scan job. It is the agent's equivalent of trying a tool by hand: nothing is written to the job registry or the inventory, and findings only enter the workspace if the agent [proposes](https://docs.oasm.io/vulnerability.md#ai-proposals-and-review) them and a reviewer approves.

Before the run starts:

* the connector must be installed in the workspace, and the target must pass the [scope gate](https://docs.oasm.io/architecture/ai-agent/safety.md#the-scope-gate);
* configuration is merged from the chosen or default profile and the model's inline values. Inline values may only set fields of the connector's schema, may never set a secret field, and the result must fill every required field — otherwise the run is refused with the names of the missing fields;
* the connector's own resource limits and egress setting apply as for a job, and the run waits at most five minutes.

If the agent stops waiting — timeout or user stop — the worker is told to cancel the run. If the worker disconnects, the run fails at once instead of waiting out its timeout.

## Browser sessions

Commands that start with `browser ` drive a headless Chromium on the worker: open a page, click, type, run JavaScript, read the console and network log. They are parsed and executed by the worker itself, not by a shell.

* Each session is a separate incognito context, identified by a random id that is the session's only credential; sessions are closed after 10 minutes idle, at most eight live per worker.
* Every command returns a screenshot of the page, shown in the console's **Browser** panel as the agent works.
* The browser starts with a minimal environment, refuses downloads, and on a sandboxed worker sends each session's traffic through a per-session proxy that allows **public addresses only**, checked after DNS resolution, so pages cannot reach the worker's network or cloud metadata.

## Across API replicas

A worker's command stream is open to exactly one core API replica, which may not be the one running the agent. The runtime handles this with the platform's **broadcast, holder acts** pattern:

* the running replica subscribes to a Redis channel for the session **before** pushing the command, so a fast command cannot finish unseen;
* the push is delivered by whichever replica holds the worker's stream;
* the worker's results are published to the channel, and the waiting replica collects them until exit, error or timeout;
* a result is accepted only from the worker the command was sent to.

See [Scaling and high availability](https://docs.oasm.io/architecture/scaling.md#broadcast-holder-acts).

## Related

> [card] [Worker and connector runtime](https://docs.oasm.io/architecture/worker-runtime.md)
>
> Worker identity, the sandbox and connector isolation

> [card] [Guard and approvals](https://docs.oasm.io/architecture/ai-agent/safety.md)
>
> The checks every command passes first

> [card] [Chat](https://docs.oasm.io/ai-studio/chat.md)
>
> Picking a worker in the composer


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