# Logs and waiting

A long log does not have to go into your agent's context, and nobody has to ask “is it done yet?” in a loop – read a compact digest and let the server wait for you.

## Log digest for AI

`GET /v1/jobs/{id}/logs?mode=summary&max_chars=6000` returns a compact digest: recognised test results, the error lines with context (repeated lines collapsed, e.g. `[×200]`) and the end of the log. `mode=errors` returns only the error blocks, `mode=tail` only the end; without `mode` you get raw bytes.

**Python**

```
print(job.digest(mode="summary", max_chars=2000))
print(job.test_results())
for chunk in job.follow():                        # new log text while it runs
    print(chunk, end="")
```

**curl**

```
curl -s -H "X-API-Key: $WBXSANDBOX_API_KEY" "https://sandbox.wbx.cz/v1/jobs/job_…/logs?mode=summary&max_chars=2000"
```

```
{
  "mode": "summary", "status": "failed", "exit_code": 1, "lines": 5214, "size": 412880,
  "text": "[wbx] tests (pytest): 211 passed, 1 failed, 212 total\n  FAILED tests/test_api.py::test_refund – AssertionError: 400 != 200\n[wbx] errors:\n…\n[wbx] end of log:\n…",
  "test_results": [{"framework": "pytest", "passed": 211, "failed": 1, "total": 212,
                    "failures": [{"name": "tests/test_api.py::test_refund", "file": "tests/test_api.py", "message": "AssertionError: 400 != 200"}]}]
}
```

Recognised output: pytest, `go test`, Jest, Vitest, `cargo test`, PHPUnit, JUnit (Maven/Gradle) and mocha. Test results are also part of the job summary and the execution receipt (`test_results`). Over MCP, `get_job_logs` returns this digest by default.

## Raw log

`GET /v1/jobs/{id}/logs?offset=&limit=` returns part of the output log; a negative offset reads from the end. It is updated every few seconds while the job runs. In Python: `job.logs(offset=0, limit=65536)` or `job.log_text()` for the whole log.

## Waiting for results

Instead of asking for the status again and again, wait on the server: `POST /v1/jobs/wait` returns as soon as one (`"until": "any"`, default) or all (`"all"`) of the given jobs or batches have finished, or after `timeout_s` (max 60) with `"done": false` – then call again.

**Python**

```
from wbxsandbox import wait_jobs

wait_jobs(["job_…", "job_…"], batch_ids=["bat_…"], until="any", timeout_s=60)
job.wait()                                        # one job, until it ends
```

**curl**

```
curl -s -X POST -H "X-API-Key: $WBXSANDBOX_API_KEY" -H "Content-Type: application/json" \
  -d '{"job_ids": ["job_…", "job_…"], "batch_ids": ["bat_…"], "until": "any", "timeout_s": 60}' https://sandbox.wbx.cz/v1/jobs/wait
{"done": true, "finished": 1, "total": 3, "items": [{"id": "job_…", "kind": "job", "status": "completed", "done": true}, …]}
```

For a notification without waiting at all, use a [webhook](https://sandbox.wbx.cz/docs/jobs/webhooks.md).

Source: https://sandbox.wbx.cz/docs/jobs/logs
