# Agents

> Write an agent definition, run it from a file or from your bucket, follow its events, read its runs, outputs and transcripts, and bring your own image.

Source: https://docs.compute.dev.ddcdragon.com/guides/agents/

An agent is a `cere.agent/v1` definition plus an image; each run is a new sandbox that the CLI or the SDK drives and
then terminates, keeping the output and the transcript. For how a run works, see [Agents](https://docs.compute.dev.ddcdragon.com/concepts/agents/).

## Write a definition

A definition is one JSON document. This is the `research` example, which writes cited briefs from one allowed site:

```json title="research.json"
{
  "schema": "cere.agent/v1",
  "name": "research",
  "description": "Evidence-grounded briefs from public sources, every claim cited and dated ...",
  "harness": "claude-code",
  "image": "cerebellumnetwork/ddc-agent-runner:0.1.1",
  "command": null,
  "system_prompt": "You are a researcher. You produce briefs someone will act on, so every claim carries a source that person could open. ...",
  "model": {
    "base_url": "https://inference-gateway.compute.dev.ddcdragon.com/anthropic",
    "model": "glm-5.3",
    "credential": "ddc-inference"
  },
  "tools": ["Read", "Grep", "Glob", "WebFetch"],
  "policy": "read-only",
  "deny": [],
  "max_turns": 20,
  "resources": {"cpu": 1, "memory_mib": 1024},
  "timeout_s": 600,
  "egress": {"allow": [{"host": "gvisor.dev", "methods": ["GET"]}]},
  "files": {}
}
```

> Until `cere` is on PyPI, download the example definitions (`research.json`, `sre.json`, `langgraph.json`) from the GitHub release instead (members of the Cerebellum-Network organization, with `gh` signed in): `gh release download cli/v0.1.7 -R Cerebellum-Network/ddc-node -p '*.json'`

| Field | Type | Default | Meaning |
|---|---|---|---|
| `schema` | string | required | `cere.agent/v1`. |
| `name` | string | required | Lower-case letters, digits and `-`, at most 63 characters. Names the definition in your bucket and labels its runs. |
| `description` | string | none | One line; `cere agent list` shows it. |
| `harness` | string | required | `claude-code` or `container`; see [Harnesses](#harnesses). |
| `image` | string | required | The image the run's sandbox runs, from a public registry. |
| `command` | array of strings | none | What a `container` run executes; required for `container`, unused by `claude-code`. |
| `system_prompt` | string | none | The agent's instructions. `claude-code` adds sections about the sandbox to it. |
| `model.base_url` | string | required | An Anthropic-compatible endpoint, `https` or `http` on port 443 or 80. The run reaches its host (`GET`, `POST` under its path) with `model.credential` added, and gets it as `ANTHROPIC_BASE_URL`. |
| `model.model` | string | required | The model id; the run gets it as `DDC_MODEL`. |
| `model.credential` | string | none | The secret the egress proxy adds to model calls. |
| `tools` | array of strings | `[]` | `claude-code`: the Claude Code tools the agent may use, such as `Bash`, `Read`, `Write`, `Edit`, `Grep`, `Glob`, `WebFetch`, `WebSearch`. |
| `policy` | string | `read-only` | `claude-code`: `read-only` refuses `Write` and `Edit` outside `/workspace/` and shell commands that change things (`git push`, `gh pr create`, `kubectl apply`, ...); `read-write` allows them. |
| `deny` | array of strings | `[]` | `claude-code`: regular expressions; a `Bash` command that matches one is refused. |
| `max_turns` | integer | 30 | `claude-code`: the turn limit; a run that reaches it fails. |
| `resources.cpu` | number | 1 | vCPUs reserved for the run's sandbox. |
| `resources.memory_mib` | integer | 2048 | Memory reserved, in MiB. |
| `timeout_s` | integer | 900 | How long the agent may run, in seconds, at most 86400. The harness is stopped after `timeout_s` or 3600 s, whichever is less; the sandbox's own timeout is 120 s longer, so the output can still be read. |
| `egress.allow` | array of rules | `[]` | The hosts the run may reach: `{"host", "methods", "path_prefix", "credential"}`, as in [egress rules](https://docs.compute.dev.ddcdragon.com/guides/egress-and-secrets/). Methods are upper case. |
| `files` | object | `{}` | Path to text content, written into the sandbox before the run; a relative path is under `/workspace`. |

The whole document reaches the sandbox as `/workspace/agent.json`, fields the client does not know included, so a
harness can read options of its own. The CLI and the SDK check a definition before a run and list every problem:

```json title="bad.json"
{"schema": "cere.agent/v1", "name": "My Agent", "harness": "container", "image": "python:3.12-slim",
 "model": {"base_url": "https://models.example.com:8443/v1", "model": "m"}}
```

```sh
cere agent run -f bad.json "hello"
```

```
error: name "My Agent": use lower-case letters, digits and '-', at most 63 characters
harness "container" needs a command
model.base_url: "https://models.example.com:8443/v1": the egress proxy allows only ports 443 and 80
```

## Harnesses

The harness is what runs the agent inside the sandbox.

| Harness | Image | What runs |
|---|---|---|
| `claude-code` | `cerebellumnetwork/ddc-agent-runner:0.1.1` | Claude Code, through the Claude Agent SDK, with the definition's system prompt, tools, policy, `deny` rules and turn limit. The image also has `gh`, `git`, `curl`, `jq`, `python3` and `ripgrep` for the agent's shell. |
| `container` | yours | The definition's `command`, in the definition's `image`. See [Bring your own image](#bring-your-own-image). |

## Store the model key

The examples call `glm-5.3` on the devnet inference gateway with the secret `ddc-inference`. That gateway takes your
login token as the key for your bucket, and bills the calls to it. Store it once:

**CLI**

```sh
cere secret set ddc-inference --from-login
```

```
Stored secret ddc-inference (header Authorization): your login token for bucket <bucket-id>, sent only to inference-gateway.compute.dev.ddcdragon.com.
It stops working when that token expires, 2026-12-24T21:57:01Z (in 29d05h); after your next cere login, run this again.
```

**Python**

```python
import cere

cere.Secret.set_from_login("ddc-inference")
```

The secret holds the token of your current login, so it stops working when the login expires: store it again after
the next `cere login`. A model on another gateway takes that gateway's key, stored with
`cere secret set <name> --header Authorization --host <its host> --bearer-stdin`.

Before it creates anything, a run checks that the bucket holds every secret the definition names, and stops with
what each missing one is for and the command that stores it. Here a copy of `research.json` names the model key
`my-model-key` and adds a rule with the secret `example-token`:

**CLI**

```sh
cere agent run -f my-research.json "hello"
```

```
agent my-research (claude-code, cerebellumnetwork/ddc-agent-runner:0.1.1)
error: the run needs the secrets my-model-key, example-token, which the bucket does not hold (cere secret list shows what it holds):
  my-model-key: the model's key (glm-5.3 at https://inference-gateway.compute.dev.ddcdragon.com/anthropic); that gateway takes your login token as the key for your bucket, and the secret stops working when the token expires (cere whoami shows when)
    cere secret set my-model-key --from-login
  example-token: added by the egress proxy to the sandbox's requests to api.example.com (GET)
    cere secret set example-token --header Authorization --host api.example.com --bearer-stdin < token.txt   (another header: --header <name> --value-stdin)
```

**Python**

```python
import cere

agent = cere.Agent.from_file("my-research.json")
try:
    agent.run("hello")
except cere.MissingSecretsError as e:
    print(e.missing)
```

```
['my-model-key', 'example-token']
```

## Run an agent from a file

`cere agent run -f FILE INPUT` runs a local definition; it needs no bucket storage. Events stream to stderr as they
happen, and the answer goes to stdout. `-` as the input reads it from stdin.

**CLI**

```sh
cere agent run -f research.json "Write a short brief on how gVisor isolates containers, citing https://gvisor.dev/docs/"
```

```
agent research (claude-code, cerebellumnetwork/ddc-agent-runner:0.1.1)
  . sandbox sb-01m89qyq974s8e3py4r9n5n9th placed on node 9f97fd7fc247; starting cerebellumnetwork/ddc-agent-runner:0.1.1
  sandbox sb-01m89qyq974s8e3py4r9n5n9th on node 9f97fd7fc247, started in 178 ms
  . running ddc-agent-run /workspace/agent.json /workspace/input.txt
  . agent research: harness claude-code, model glm-5.3, policy read-only
  ...
  > WebFetch https://gvisor.dev/docs/
  < ok (2957 chars) # gVisor: What It Is
  > WebFetch https://gvisor.dev/docs/arch_guide/platforms/
  < ok (215 chars) The server returned HTTP 404 Not Found.
  ...
  > WebFetch https://gvisor.dev/docs/architecture_guide/platforms/
  < ok (1965 chars) # How gVisor Intercepts System Calls
  ...
  . harness finished in 95.5s

# How gVisor isolates containers — brief

**Conclusion.** gVisor isolates containers not by filtering syscalls or running a full VM, but by interposing its own userspace application kernel ...

run 01m89qyps8xg0r286vzvmmb8mx, sandbox sb-01m89qyq974s8e3py4r9n5n9th: 5 turns, 4 tool calls, 99.4 s, model tokens in 19336 out 2045
sandbox terminated: terminated by API: agent run succeeded; usage: wall 99.0s, cpu 7.82s, memory peak 254 MiB, ...
billed 1.0 vCPU × 99.0 s = 99.0 CPU-s (measured 7.8), 1.0 GiB × 99.0 s = 99.0 GiB-s (measured 21.8)
retained: /workspace/agent.json, /workspace/input.txt, /workspace/output.json, /workspace/output.md, /workspace/transcript.jsonl (cere sandbox get-file sb-01m89qyq974s8e3py4r9n5n9th <path>)
error: null
```

**Python**

```python
import cere

def show(name, fields):
    if name == "tool_call":
        print(">", fields["tool"], fields["input"])

agent = cere.Agent.from_file("research.json")
res = agent.run(
    "Write a short brief on how gVisor isolates containers, citing https://gvisor.dev/docs/",
    on_event=show,
)
print(res.error or res.output)
print(res.sandbox_id, res.turns, "turns,", res.tool_calls, "tool calls")
```

```
> WebFetch {'url': 'https://gvisor.dev/docs/', 'prompt': 'Summarize what this page says about how gVisor isolates containers: ...'}
> WebFetch {'url': 'https://gvisor.dev/docs/architecture_guide/security/', 'prompt': "What does this page say about gVisor's security architecture, ..."}
> WebFetch {'url': 'https://gvisor.dev/docs/architecture_guide/platforms/', 'prompt': 'What does this page say about how gVisor intercepts application system calls ...'}
...
# Brief: How gVisor isolates containers

**Conclusion.** gVisor isolates containers by interposing a userspace application kernel (the "Sentry") between the container and the host kernel ...
...
sb-01m89qnh5erh2xb8t1mb2n8wmj 5 turns, 4 tool calls
```

`agent.run` returns an `AgentResult`: `output`, `error` (the agent's own failure, empty when it worked), `turns`,
`tool_calls`, `model_usage`, `exit_code`, `run_id`, `sandbox_id`, and `sandbox`, the sandbox's final state with its
usage. A failure of the API itself raises `cere.CereError`. `cere --json agent run` prints the result as JSON with
the same field names.

A run exits non-zero when the agent fails. Ctrl-C stops it: the sandbox is terminated and the run is recorded as
`stopped`.

### The run's events

| Event | Fields | When |
|---|---|---|
| `sandbox` | `sandbox_id`, `node`, `startup_ms`, `image`, `run` | The sandbox is running. |
| `log` | `message`, `stream` | A step of the client, a log line of the harness, or its stderr (`stream` is `stderr`). |
| `text` | `text` | The model wrote text. |
| `tool_call` | `tool`, `input`, `id` | The agent called a tool. |
| `tool_result` | `id`, `output`, `is_error` | The tool answered. |
| `denied` | `tool`, `input`, `reason` | The `claude-code` policy refused a tool call. |
| `output` | `output` | The final answer. |
| `done` | `turns`, `tool_calls`, `error`, `model_usage` | The harness finished. |

The CLI prints `>` for a tool call, `<` for its result, `x` for a refusal and `.` for a log line. In Python,
`on_event(name, fields)` receives each one.

## Add hosts and files for one run

`--allow` adds an egress rule, `--file local=remote` puts a local file in the sandbox (a relative remote path is
under `/workspace`), and `--label key=value` labels the run's sandbox, for this run only. `--keep` leaves the sandbox
running after the run, so you can look inside; terminate it yourself. Its run then shows as `ended`, and its files are
not kept unless you terminate it with `--retain`.

**CLI**

```sh
cere agent run -f research.json --allow peps.python.org:GET --file notes.md=notes.md --label team=docs --keep \
  "Check the claim in notes.md against https://peps.python.org/pep-0008/"
cere sandbox exec sb-01m89r2hdh0gad2g7sv613gp4f -- ls /workspace
cere sandbox terminate sb-01m89r2hdh0gad2g7sv613gp4f
```

```
agent research (claude-code, cerebellumnetwork/ddc-agent-runner:0.1.1)
  . sandbox sb-01m89r2hdh0gad2g7sv613gp4f placed on node d4007f488e29; starting cerebellumnetwork/ddc-agent-runner:0.1.1
  ...
  > Read /workspace/notes.md
  < ok (53 chars) 1	PEP 8 says to use 2 spaces per indentation level.
  > WebFetch https://peps.python.org/pep-0008/
  < ok (898 chars) PEP 8's core rule on indentation is short: "Use 4 spaces per indentation level."
  ...

**The claim in notes.md is false.** PEP 8 recommends 4 spaces per indentation level, not 2.
...

run 01m89r2gttqx6n2m039mjs1b7k, sandbox sb-01m89r2hdh0gad2g7sv613gp4f: 4 turns, 3 tool calls, 33.6 s, model tokens in 11018 out 506
sandbox sb-01m89r2hdh0gad2g7sv613gp4f left running (cere sandbox terminate sb-01m89r2hdh0gad2g7sv613gp4f)
error: null
agent.json
input.txt
notes.md
output.json
output.md
system_prompt.md
transcript.jsonl
sb-01m89r2hdh0gad2g7sv613gp4f terminated: terminated by API
...
```

**Python**

```python
import cere

agent = cere.Agent.from_file("research.json")
res = agent.run(
    "Check the claim in notes.md against https://peps.python.org/pep-0008/",
    egress=[cere.Allow("peps.python.org", ["GET"])],
    files={"notes.md": open("notes.md").read()},
    labels={"team": "docs"},
    keep=True,
)
print(res.error or res.output)

sb = cere.Sandbox.from_id(res.sandbox_id)
print(sb.exec("ls", "/workspace").stdout.read(), end="")
sb.terminate()
```

```
**The claim in notes.md is false.** PEP 8 recommends 4 spaces per indentation level, not 2.
...
agent.json
input.txt
notes.md
output.json
output.md
system_prompt.md
transcript.jsonl
```

A label key must not start with `cere.`: the agent layer sets `cere.kind=agent-run`, `cere.agent`, `cere.harness`
and `cere.run` on every run.

## Run an agent by name from your bucket

Definitions you keep in your bucket are stored at `cere/agents/<name>.json`, and the CLI, the SDK and the Developer
Console's **Agents** page all read them. Reaching them needs an S3 credential: create one in Developer Console >
**Access tokens** > **Agent definitions in your bucket**, then add it to your login:

```sh
cere login --s3-access-key-id <access key id> --s3-bucket <bucket name> --s3-secret-stdin < s3-secret.txt
```

**CLI**

```sh
cere agent push -f research.json      # validate and store as cere/agents/research.json
cere agent list                       # name, harness, image, description
cere agent show research              # print it
cere agent pull research              # write research.json (-o FILE, or -o - for stdout)
cere agent run research "Write a short brief on how gVisor isolates containers, citing https://gvisor.dev/docs/"
cere agent delete research            # its past runs stay
```

**Python**

```python
import cere

cere.Agent.from_file("research.json").push()   # returns "cere/agents/research.json"
print(cere.Agent.list_bucket())
agent = cere.Agent.from_bucket("research")
res = agent.run("Write a short brief on how gVisor isolates containers, citing https://gvisor.dev/docs/")
print(res.bucket_keys)
```

With an S3 credential set, every run, by name or from a file, also copies `output.json` and `transcript.jsonl` to
`cere/runs/<sandbox-id>/` in the bucket, and says so (`saved to the bucket: ...`; `res.bucket_keys` in Python).
`CERE_S3_ENDPOINT`, `CERE_S3_BUCKET`, `CERE_S3_ACCESS_KEY_ID` and `CERE_S3_SECRET_ACCESS_KEY` set the credential
without saving it.

## List runs and their results

Every run is a sandbox labelled `cere.kind=agent-run`, and it records its result as its exit reason, so the CLI, the
SDK and the Developer Console show the same result for any run.

**CLI**

```sh
cere agent runs --limit 5
cere agent runs --agent langgraph --limit 3
```

```
RUN                         AGENT      HARNESS      RESULT     STARTED  WALL  CPU-S  SANDBOX                        DETAIL
01m89r8ea96frbg2vt17ye1a1t  langgraph  container    succeeded  1m ago   13s   7.15   sb-01m89r8et3bd3nd6erk9fq3x0c
01m89r5rrd3b48c76wbe9d3n1k  research   claude-code  ended      2m ago   29s   4.04   sb-01m89r5se4y5ewkmy6bxq5mxgg  terminated by API
01m89r5q86ebzdnp2rjm12qs3e  sre        claude-code  succeeded  2m ago   129s  14.23  sb-01m89r5qqghy8pr728xv059s4x
01m89r5e6jt2rfdznyvc82cas8  research   claude-code  ended      2m ago   6s    2.54   sb-01m89r5ew1ekr6ms7sqrshz392  terminated by API
01m89r5e018zztvx6pxm8z3qxs  sre        claude-code  failed     2m ago   4s    2.60   sb-01m89r5efw59g0pdmf9gtr1k8j  There's an issue with the selected model (glm-5.3). It may not exist or you may not have a...
(the newest 5 runs; there are more: raise --limit, or --all for every one)

RUN                         AGENT      HARNESS    RESULT     STARTED  WALL  CPU-S  SANDBOX                        DETAIL
01m89r8ea96frbg2vt17ye1a1t  langgraph  container  succeeded  1m ago   13s   7.15   sb-01m89r8et3bd3nd6erk9fq3x0c
01m89qxqeqcc6hsrphhjf5mk6m  langgraph  container  succeeded  6m ago   15s   8.49   sb-01m89qxr4ratzaw8wmwtqyn4dz
01m89qwv34wk58vykearzyq9en  langgraph  container  failed     7m ago   22s   8.55   sb-01m89qwvrv5tpmnh6t686tfz4d  AnthropicModelNotFoundError: Error code: 404 - {'type': 'error', 'error': {'type': 'not_fo...
(the newest 3 runs; there are more: raise --limit, or --all for every one)
```

**Python**

```python
import cere

for sb in cere.Sandbox.list(label="cere.kind=agent-run", limit=5):
    outcome = cere.run_outcome(sb)
    print(sb.id, sb.data["labels"]["cere.agent"], outcome.state, outcome.detail)
```

```
sb-01m89r8et3bd3nd6erk9fq3x0c langgraph succeeded
sb-01m89r5se4y5ewkmy6bxq5mxgg research ended terminated by API
sb-01m89r5qqghy8pr728xv059s4x sre succeeded
sb-01m89r5ew1ekr6ms7sqrshz392 research ended terminated by API
sb-01m89r5efw59g0pdmf9gtr1k8j sre failed There's an issue with the selected model (glm-5.3). It may not exist or you may not have access to it.
```

| Result | Meaning |
|---|---|
| `succeeded` | The agent finished without an error. |
| `failed` | The agent's error (the harness, the model, no output, the time limit), or the sandbox failed or ended under the run. |
| `stopped` | Its client stopped it (Ctrl-C, the console's Stop). |
| `running` | The run is still going. |
| `ended` | The sandbox ended without a recorded result: a `--keep` run you terminated or that reached its timeout, or a sandbox terminated from elsewhere. |
| `unknown` | The sandbox's node has not reported for a while, or the result was not kept. |

`--status running|terminated|failed` filters by the sandbox's status, and `--all` lists every run.

A run that fails with `There's an issue with the selected model` (`claude-code`) or a `404` naming the model
(`container`) could not reach the model at that moment; see [Limits and errors](https://docs.compute.dev.ddcdragon.com/guides/inference/#limits-and-errors).
Run it again.

## Read the output and the transcript

A run keeps five files readable after its sandbox has ended:

| File | What |
|---|---|
| `/workspace/output.json` | `{output, turns, tool_calls, model_usage, error}` (the agent runner adds a few more fields) |
| `/workspace/output.md` | The answer as text |
| `/workspace/transcript.jsonl` | Every message of the run, one JSON object per line |
| `/workspace/agent.json` | The definition the run used |
| `/workspace/input.txt` | The input |

**CLI**

```sh
cere sandbox get-file sb-01m89qyq974s8e3py4r9n5n9th /workspace/output.md
cere sandbox get-file sb-01m89qyq974s8e3py4r9n5n9th /workspace/transcript.jsonl transcript.jsonl
```

```
# How gVisor isolates containers — brief

**Conclusion.** gVisor isolates containers not by filtering syscalls or running a full VM, but by interposing its own userspace application kernel ...
...
wrote sb-01m89qyq974s8e3py4r9n5n9th:/workspace/transcript.jsonl (201.7 KiB) to transcript.jsonl
```

**Python**

```python
import collections
import json

import cere

sb = cere.Sandbox.from_id("sb-01m89qyq974s8e3py4r9n5n9th")
out = json.loads(sb.read_file("/workspace/output.json"))
print(out["turns"], out["tool_calls"], out["model_usage"]["output_tokens"])
lines = sb.read_file("/workspace/transcript.jsonl").decode().splitlines()
print(collections.Counter(json.loads(line)["kind"] for line in lines))
```

```
5 4 2045
Counter({'SystemMessage': 502, 'AssistantMessage': 10, 'UserMessage': 4, 'input': 1, 'ResultMessage': 1})
```

`res.transcript()` on an `AgentResult` returns the transcript as a list of dicts.

Kept files stay readable for 24 hours ([retained files](https://docs.compute.dev.ddcdragon.com/guides/sandboxes/#terminate-a-sandbox-and-keep-files)); a
file the run did not keep answers `410 file_gone`.

## The example agents

| Agent | Harness | What it does | Reaches | Secrets |
|---|---|---|---|---|
| `research` | `claude-code` | Writes a brief from public sources, every claim cited and dated. | `gvisor.dev` (GET) | `ddc-inference` |
| `sre` | `claude-code` | Reports a GitHub repository's state, read-only: commits, CI runs, releases, pull requests. | `api.github.com` (GET, with `github-readonly`), `github.com` (GET) | `ddc-inference`, `github-readonly` |
| `langgraph` | `container` | A LangGraph agent in its own image that answers questions about Python packages from PyPI. | `pypi.org` (GET under `/pypi/`) | `ddc-inference` |

```sh
cere agent run -f research.json "Write a short brief on how gVisor isolates containers, citing https://gvisor.dev/docs/"
cere agent run -f sre.json "Read-only status of github.com/google/gvisor: last 3 commits on master, latest CI runs, open PRs"
cere agent run -f langgraph.json "What is the latest release of langgraph on PyPI and how many days ago was it uploaded?"
```

`sre` also needs `github-readonly`: a fine-grained GitHub personal access token
(https://github.com/settings/personal-access-tokens/new) with read access only, to public repositories or to the
ones it reads. Do not use `gh auth token`, which carries every scope of your `gh` login.

```sh
cere secret set github-readonly --header Authorization --host api.github.com --bearer-stdin < github-token.txt
```

The `sre` run then works through `gh api` calls, every one a GET that the egress proxy sends to `api.github.com` with
your token:

```
agent sre (claude-code, cerebellumnetwork/ddc-agent-runner:0.1.1)
  ...
  > Bash gh api repos/google/gvisor --jq '{full_name, default_branch, pushed_at, open_issues_count, archived, html_url}'
  > Bash gh api 'repos/google/gvisor/commits?sha=master&per_page=3' --jq ...
  < ok (178 chars) {"archived":false,"default_branch":"master","full_name":"gvisor/gvisor","html_url":"https://github.com/gvisor/gvisor","o...
  ...

## Status: healthy

`gvisor/gvisor` (redirected from `google/gvisor`) is active and unarchived, pushed today (2026-11-25T09:59:42Z), with every per-push workflow green on the last 3 master commits ...

run 01m89r5q86ebzdnp2rjm12qs3e, sandbox sb-01m89r5qqghy8pr728xv059s4x: 22 turns, 21 tool calls, 129.7 s, model tokens in 165897 out 7664
...
error: null
```

## Bring your own image

With `"harness": "container"`, the run executes your `command` in your `image`. The image must:

- read the input from `/workspace/input.txt` and the definition from `/workspace/agent.json`;
- write `/workspace/output.json`: `{"output": ..., "turns": ..., "tool_calls": ..., "model_usage": ..., "error": ...}`,
  with `error` `null` when it worked (a command that writes none but prints its answer has that output used instead);
- call the model at `ANTHROPIC_BASE_URL` with the key in `ANTHROPIC_API_KEY`, a placeholder that the egress proxy
  replaces with the definition's `model.credential`; `DDC_MODEL` is the model id;
- have `sh` and `sleep`: the sandbox waits with `sleep infinity`, and the run executes your command in it;
- end its `ENTRYPOINT`, if it has one, with `exec "$@"`, so that `sleep infinity` and your command run.

A non-zero exit fails the run, as does an `error` in `output.json`.

It may print the [events](#the-runs-events) as JSON lines on stdout (`{"event": "tool_call", "tool": ..., ...}`); the
CLI and the SDK relay them, and show any other line as a log line.

:::caution[Trust the egress proxy's CA]
Every HTTPS request from a sandbox goes through the egress proxy, whose certificates are signed by the cluster's CA.
The sandbox has it at `/etc/ddc/egress-ca.crt`, and `SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`,
`CURL_CA_BUNDLE` and `GIT_SSL_CAINFO` point at it. A program that verifies against its own root set (httpx with
certifi, Java, Go with pinned roots) must add the CA itself.
:::

The `langgraph` example is a LangGraph ReAct agent with two tools, packaged as anyone would. Its definition names the
image and the command:

```json title="langgraph.json (excerpt)"
{
  "harness": "container",
  "image": "cerebellumnetwork/ddc-example-langgraph-agent:0.1.1",
  "command": ["/app/entrypoint.sh", "python", "/app/agent.py"],
  "model": {
    "base_url": "https://inference-gateway.compute.dev.ddcdragon.com/anthropic",
    "model": "glm-5.3",
    "credential": "ddc-inference"
  },
  "egress": {"allow": [{"host": "pypi.org", "methods": ["GET"], "path_prefix": "/pypi/"}]}
}
```

Its Dockerfile installs LangGraph and runs everything through the entrypoint:

```dockerfile title="Dockerfile"
FROM python:3.12-slim

ARG LANGGRAPH_VERSION=1.2.24
ARG LANGCHAIN_ANTHROPIC_VERSION=1.7.12
RUN pip install --no-cache-dir "langgraph==${LANGGRAPH_VERSION}" "langchain-anthropic==${LANGCHAIN_ANTHROPIC_VERSION}"

COPY entrypoint.sh agent.py /app/
RUN chmod 0755 /app/entrypoint.sh \
    && useradd --create-home --uid 10001 agent && mkdir -p /workspace && chown agent:agent /workspace
USER agent
WORKDIR /workspace
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1

ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["python", "/app/agent.py"]
```

The entrypoint adds the egress proxy's CA to certifi's bundle, then runs the command:

```sh title="entrypoint.sh"
#!/bin/sh
set -eu
ca=/etc/ddc/egress-ca.crt
if [ -r "$ca" ]; then
  bundle=/tmp/ddc-ca-bundle.pem
  cat "$(python -c 'import certifi; print(certifi.where())')" "$ca" > "$bundle"
  export SSL_CERT_FILE="$bundle" REQUESTS_CA_BUNDLE="$bundle"
fi
exec "$@"
```

The agent reads the definition and the input, and writes the output and its events:

```python title="agent.py (excerpt)"
WORK = Path(os.environ.get("DDC_WORKDIR", "/workspace"))

def main() -> int:
    definition = load_definition()  # /workspace/agent.json
    question = sys.argv[1] if len(sys.argv) > 1 else (WORK / "input.txt").read_text()
    ...
    model = ChatAnthropic(
        model=model_name,
        base_url=os.environ.get("ANTHROPIC_BASE_URL"),
        api_key=os.environ.get("ANTHROPIC_API_KEY", "unset"),
        max_tokens=2048, timeout=300, max_retries=1,
    )
    agent = create_react_agent(model, [pypi_latest, days_since], prompt=definition.get("system_prompt") or DEFAULT_PROMPT)
    ...  # stream the agent, print {"event": ...} lines, append to transcript.jsonl
    out = {"output": answer, "turns": turns, "tool_calls": calls, "model_usage": usage, "error": error or None,
           "harness": "langgraph"}
    (WORK / "output.json").write_text(json.dumps(out, indent=2))
    (WORK / "output.md").write_text(answer or f"(no output) {error}")
    emit("output", output=answer)
    emit("done", turns=turns, tool_calls=calls, error=error or None, model_usage=usage)
    return 1 if error else 0
```

Run it like any agent:

**CLI**

```sh
cere agent run -f langgraph.json "What is the latest release of langgraph on PyPI and how many days ago was it uploaded?"
```

```
agent langgraph (container, cerebellumnetwork/ddc-example-langgraph-agent:0.1.1)
  . sandbox sb-01m89qnkwpqm5zyvre8qp6f2ah placed on node 30a2eb37a537; starting cerebellumnetwork/ddc-example-langgraph-agent:0.1.1
  sandbox sb-01m89qnkwpqm5zyvre8qp6f2ah on node 30a2eb37a537, started in 4689 ms
  . running /app/entrypoint.sh python /app/agent.py
  . langgraph agent langgraph: model=glm-5.3 base_url=https://inference-gateway.compute.dev.ddcdragon.com/anthropic
  > pypi_latest langgraph
  < ok (156 chars) {"package": "langgraph", "version": "1.2.24", "uploaded": "2026-11-20T01:10:12.830391Z", "summary": "Building stateful, ...
  > days_since {"timestamp":"2026-11-20T01:10:12.830391Z"}
  < ok (1 chars) 5
  ...

The latest release of **langgraph** on PyPI is **version 1.2.24**, which was uploaded **5 days ago**.
...

run 01m89qnkdtt0nfsg2s29kfznzg, sandbox sb-01m89qnkwpqm5zyvre8qp6f2ah: 3 turns, 2 tool calls, 17.9 s, model tokens in 1648 out 218
sandbox terminated: terminated by API: agent run succeeded; usage: wall 13.1s, cpu 7.92s, memory peak 139 MiB, ...
billed 1.0 vCPU × 13.1 s = 13.1 CPU-s (measured 7.9), 1.0 GiB × 13.1 s = 13.1 GiB-s (measured 1.2)
retained: /workspace/agent.json, /workspace/input.txt, /workspace/output.json, /workspace/output.md, /workspace/transcript.jsonl (cere sandbox get-file sb-01m89qnkwpqm5zyvre8qp6f2ah <path>)
error: null
```

**Python**

```python
import cere

agent = cere.Agent.from_file("langgraph.json")
res = agent.run("What is the latest release of langgraph on PyPI and how many days ago was it uploaded?")
print(res.error or res.output)
print(res.sandbox_id, res.sandbox["status"], res.sandbox["exit_reason"])
```

```
The latest release of **langgraph** on PyPI is **version 1.2.24**, which was uploaded **5 days ago**.
...
sb-01m89qxr4ratzaw8wmwtqyn4dz terminated terminated by API: agent run succeeded
```

Push your image to a public registry, point `image` and `command` at it, and run it the same way.

## Related

- [Next: Inference API](https://docs.compute.dev.ddcdragon.com/guides/inference/)
- [Agents concepts](https://docs.compute.dev.ddcdragon.com/concepts/agents/)
- [Egress and secrets](https://docs.compute.dev.ddcdragon.com/guides/egress-and-secrets/)
- [Sandboxes](https://docs.compute.dev.ddcdragon.com/guides/sandboxes/)
- [CLI reference](https://docs.compute.dev.ddcdragon.com/reference/cli/)
