# Watching what an agent's sandbox is doing: CPU, memory, disk and run history

> Use sandscale sandbox list, show, metrics and logs to see which sandboxes your agents started, how hard they are working, and what each command printed. Plus the run record API for cost per run.

Use sandscale sandbox list, show, metrics and logs to see which sandboxes your agents started, how hard they are working, and what each command printed. Plus the run record API for cost per run.

November 27, 2026 · 4 min read · The Sandscale team

**Short answer:** four CLI commands answer most “what is my agent doing in there?” questions. `sandscale sandbox list` shows which sandboxes exist, `sandscale sandbox metrics ID --follow` shows CPU, memory and disk use as it happens, `sandscale sandbox logs ID` lists the commands that ran, and `--run RUN_ID` prints one command’s output. For code, `GET /api/v1/sandbox/runs/{id}` returns a run’s details and cost.

Everything below is from the live [`sandscale sandbox` reference](https://sandscale.dev/docs/reference/cli/sandbox), [`sandscale logs` reference](https://sandscale.dev/docs/reference/cli/logs) and [sandboxes API guide](https://sandscale.dev/docs/guides/sandboxes-api).

## Which sandboxes are running?

```sh
sandscale sandbox list
sandscale sandbox show sbx_9
```

`list` takes `--limit N` and `--cursor C` for paging, and every command here takes `--json` for scripts. If your agents put [labels](https://sandscale.dev/blog/labels-and-run-records-for-traceability) on the sandboxes they start (`--label KEY=VALUE` on `sandscale sandbox start`, or `labels` in the SDK), you can tie each one back to a task or pull request.

A sandbox your agent forgot to stop still stops when its time limit runs out, but it counts against your plan’s vCPU-hours until then. `list` is the quickest way to spot one.

## How hard is it working?

```sh
sandscale sandbox metrics sbx_9
sandscale sandbox metrics sbx_9 --follow --interval 10s
```

`metrics` prints the sandbox’s CPU, memory and disk use. With `--follow` it prints new samples as they come, one JSON object per line with `--json`, which is easy to pipe into `jq` or a log shipper.

What to look for:

- **CPU pinned for a long time** on a task that should be quick: a loop, or a test suite that hangs waiting for something it cannot reach.
- **Memory climbing toward the box’s size**: the next command may come back with `oom_killed`. Each vCPU comes with 4 GiB; see [sizing sandboxes](https://sandscale.dev/blog/sizing-sandboxes-vcpu-memory).
- **Disk filling**: an agent writing logs or build output without cleaning up. See [resource exhaustion in agent sandboxes](https://sandscale.dev/blog/resource-exhaustion-in-agent-sandboxes).

## What did it run?

```sh
sandscale sandbox logs sbx_9
sandscale sandbox logs sbx_9 --run run_3
```

The first lists the sandbox’s runs; the second prints one run’s output. `sandscale logs sandbox ID [--run RUN_ID]` is the same view under the top-level `logs` command, next to workspace and build host logs.

This is useful after the fact: the agent’s transcript tells you what it meant to do, and the run history tells you what actually executed.

## From code: the run record

Every command run through the API is recorded. The exec answer includes a `run_id` (`runId` in the TypeScript SDK), and:

```sh
curl "https://api.sandscale.dev/api/v1/sandbox/runs/$RUN_ID" -H "Authorization: Bearer $SANDSCALE_API_KEY"
```

returns that run’s details and cost. Storing the run ID next to the agent step that caused it gives you a per-step cost without estimating. The exec answer itself already has `exit_code`, `duration_ms`, and `timed_out` and `oom_killed` flags.

## Live output while it runs

For your own code rather than a terminal, the TypeScript SDK’s `run` accepts `onStdout` and `onStderr` callbacks that receive output in order as the server releases it, and the result’s `streamed` field says whether they got live output or the final output at the end. [Streaming sandbox output in TypeScript](https://sandscale.dev/blog/streaming-sandbox-output-typescript) covers the details.

## Who did what

The CLI shows what a sandbox did. Who started it, stopped it and ran which commands is in your organization’s hash-chained audit log, which every plan can read in the console and Team and Enterprise can export. Together they cover “what happened” and “who did it”. More on how each [Sandscale sandbox](https://sandscale.dev/sandboxes) is isolated is on the product page.

## FAQ

### How do I see a Sandscale sandbox’s CPU and memory use?

Run `sandscale sandbox metrics ID`. Add `--follow` to keep printing new samples, `--interval` to change how often, and `--json` for one JSON object per line.

### How do I see what commands ran in a sandbox?

`sandscale sandbox logs ID` lists the sandbox’s runs, and `sandscale sandbox logs ID --run RUN_ID` prints one run’s output.

### Can I get the cost of a single command?

Yes. Every run through the API is recorded, and `GET /api/v1/sandbox/runs/{id}` with the run ID returns its details and cost.

### Do forgotten sandboxes keep running forever?

No. A sandbox stops by itself when its time limit runs out. Until then it counts against your plan’s vCPU-hours, so list your sandboxes and stop ones you no longer need.

## Related

- [Timeouts for agent sandboxes](https://sandscale.dev/blog/timeouts-for-agent-sandboxes)
- [Structured logging for agent runs](https://sandscale.dev/blog/structured-logging-for-agent-runs)
- [Scripting the Sandscale CLI: exit codes and JSON](https://sandscale.dev/blog/scripting-the-sandscale-cli-exit-codes-and-json)

**On this page**

1. Which sandboxes are running?
2. How hard is it working?
3. What did it run?
4. From code: the run record
5. Live output while it runs
6. Who did what
7. FAQ
8. Related

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [November 27, 2026 · **A LlamaIndex.TS data agent that runs its Python in a Sandscale sandbox** · Use LlamaIndex.TS's agent workflow with tools that write and run Python in a Firecracker sandbox, built per sandbox so a run can only reach its own box. Upload data files, answer with the numbers, clean up. Type-checked.](https://sandscale.dev/blog/llamaindex-ts-agent-with-sandscale)
- [November 27, 2026 · **A sandbox for Claude Code: running it headless in a cloud workspace** · Run Claude Code with claude -p inside a Sandscale workspace, a persistent Firecracker microVM, so its Bash tool works on a cloud disk instead of your laptop. Setup, permission flags and what stays where.](https://sandscale.dev/blog/claude-code-headless-in-a-cloud-workspace)

---
Source: https://sandscale.dev/blog/monitoring-sandbox-cpu-memory-and-runs
