###################################################################################### ONV AUTOMATION BACKEND -- API REFERENCE ###################################################################################### Version: 0.1.0 Base path: /api/v1 (unversioned /health is outside it) Format: JSON in, JSON out, over HTTPS Authentication: header X-API-Key: on every /api/v1 request Interactive docs: GET /docs (Swagger UI), /redoc, /openapi.json Admin panel: GET /admin/ (a web UI over this same API) This file is a plain-text snapshot of the API, regenerated from the running application's OpenAPI schema and tool registry -- every path, parameter and tool schema below is exactly what the code serves at the time this was generated. The live, authoritative version of the machine-readable schema is always GET /openapi.json; regenerate this file (scripts/generate_api_reference.py) after changing any endpoint or tool. See also, in docs/: api-guide.md (narrative walkthrough with a client-code sketch), adding-an-app.md and tool-authoring.md (how tools are built), browser-and-sessions.md (browser modes and logins), logging.md (tracing a run step by step), operations.md (configuration, deployment, troubleshooting), and apps/ (one page per automated app). ====================================================================================== TABLE OF CONTENTS ====================================================================================== 1. Overview and core concepts 2. Authentication 3. Conventions (pagination, IDs, timestamps, request IDs) 4. Error handling (request errors vs. run errors) 5. Endpoints 5.1 Health 5.2 Apps 5.3 Tools 5.4 Runs 5.5 Sessions 6. Request/response schemas (full field reference) 7. Tool catalogue (every tool's input/output schema, as registered right now) 8. App catalogue (every app currently registered) 9. Typical workflow and examples (curl + Python) 10. Observability: logs and the run.log artifact ====================================================================================== 1. OVERVIEW AND CORE CONCEPTS ====================================================================================== This backend runs automations ('tools') inside third-party web apps through a real browser (Playwright), and exposes them over one uniform HTTP API. A client starts a 'run' of a tool, polls or waits for it to finish, and reads back a structured result plus any artifacts (screenshots, traces, videos, files) it produced. Vocabulary App A third-party web app being automated (e.g. 'web', 'gemini'). Sessions and some browser defaults are scoped to one app. Tool One task inside one app, named '.' (e.g. 'gemini.deep_research'). A typed operation with a JSON-Schema input and output. Run One execution of a tool with concrete parameters. Has its own random 'id', an optional caller-supplied 'client_request_id', a status, a result or error, and artifacts. Runs are queued and executed asynchronously by a worker. Session A saved login for one account of one app (cookies / local storage, or a named browser profile). Tools that need to be signed in require one. Artifact A file a run produced: a screenshot, a Playwright trace, a video, or any file the tool attaches (e.g. a captured Markdown report, a run.log). Run lifecycle queued --> running --> succeeded \-> failed \-> cancelled queued --> cancelled (cancelled before a worker ever claimed it) succeeded / failed / cancelled are terminal: a run is never retried or reopened by the backend. If a tool has side effects (send, buy, delete, ...), decide whether the first attempt already took effect before submitting a new run. ====================================================================================== 2. AUTHENTICATION ====================================================================================== Every request under /api/v1 must carry the header: X-API-Key: Keys are configured server-side (the API_KEYS setting) and compared with a constant- time check. A request with no key, or a key not in that list, gets: { "error": { "code": "unauthorized", "message": "Missing or invalid API key.", "details": null, "request_id": "..." } } If API_KEYS is left empty, authentication is disabled entirely (every request is accepted) -- acceptable only for local development; the server refuses to start this way when ENVIRONMENT=production. /health/live and /health/ready never require a key. ====================================================================================== 3. CONVENTIONS ====================================================================================== Pagination List endpoints (tools, runs, sessions) return a page object: { "items": [ "..." ], "total": 0, "limit": 50, "offset": 0 } 'limit' is 1-200 (default 50 where applicable); 'offset' skips that many items. 'total' is the count matching the filters, ignoring limit/offset. Lists are newest first unless noted otherwise. Identifiers Every run and session gets a server-generated random UUID ('id'). A run also accepts an optional, caller-supplied 'client_request_id' (any string up to 200 chars, not required to be unique) so a client can recognise its own requests without storing the server id -- submit with it, then filter with GET /api/v1/runs?client_request_id=. It is stored and echoed back as-is; the server attaches no meaning to it. Timestamps All timestamps are ISO-8601 with an explicit UTC offset, e.g. '2026-11-13T10:52:58.376Z'. Request IDs Every response carries an X-Request-ID header (echoing one you send, or a generated hex id). It also appears in every error body's 'request_id' field and in every log line the request produced -- include it when reporting a problem. See docs/logging.md. ====================================================================================== 4. ERROR HANDLING ====================================================================================== There are two independent kinds of failure; do not confuse them. 4.1 The REQUEST was rejected (non-2xx HTTP status) Always this body shape: { "error": { "code": "invalid_tool_params", "message": "Invalid params for tool 'web.page_snapshot'.", "details": [ { "type": "missing", "loc": [ "url" ], "msg": "Field required" } ], "request_id": "8f0c2a..." } } HTTP code meaning ------ ------------------------ -------------------------------------------------- 401 unauthorized missing or wrong API key 404 tool_not_found no such tool 404 run_not_found no such run 404 session_not_found no such session 404 artifact_not_found no such artifact on that run 404 app_not_found no such app (internal lookups only) 404 not_found no route matches (generic 404) 409 run_already_finished cancel requested on an already-finished run 409 session_already_exists a session with that app + name already exists 422 validation_error malformed request; 'details' lists the fields 422 invalid_tool_params 'params' do not satisfy the tool's input_schema 422 session_required the tool needs a session_id and none was given 422 session_app_mismatch the session belongs to a different app than the tool 422 timeout_too_large timeout_seconds exceeds the configured maximum 500 internal_error a bug; report the request_id 4.2 The RUN was accepted but did not succeed HTTP 200 on GET /runs/{id} (the request itself was fine); status is 'failed' or 'cancelled' and an 'error' object is set on the run: { "code": "session_expired", "message": "...", "type": null } error.code meaning typical reaction ------------------ -------------------------------- -------------------------------- (tool-specific) an expected failure the tool see the tool's own doc page itself reports session_expired the saved login is no longer log in again; replace the valid session's storage state timeout the run exceeded its inspect the trace / run.log; timeout_seconds raise the limit if just slow cancelled a client cancelled it, or its start a new run if still wanted worker shut down worker_lost the worker process died mid-run check whether the tool's side effect already happened unexpected_error the tool crashed; 'type' names open the trace / run.log the exception artifact Runs are never retried automatically by the backend. Tool-specific error codes (for example 'http_error' on web.page_snapshot, or 'research_timeout' / 'deep_research_unavailable' / 'empty_report' on gemini.deep_research) are documented per tool in docs/apps/.md and in the tool catalogue below. ====================================================================================== 5. ENDPOINTS ====================================================================================== GET /health/live ----------------- Liveness probe The process is up. Responses: 200 OK status string required GET /health/ready ------------------ Readiness probe The process can reach its database. Responses: 200 OK (no fields) 503 status string required GET /api/v1/apps ----------------- List apps The apps this backend can operate. Responses: 200 OK array of: AppRead name string required Identifier; prefixes its tools and scopes its sessions. title string required description string required base_url string | null required verifies_login boolean required Runs of tools that require a session first check that the login is still valid, and fail with 'session_expired' when it is not. tools integer required Number of tools available for this app. 401 Unauthorized error ErrorBody required GET /api/v1/tools ------------------ List tools Parameters: app (query, optional) string | null Only tools of this app. Responses: 200 OK array of: ToolSummary name string required Unique tool identifier. example: "web.page_snapshot" app string required title string required description string required needs_browser boolean required requires_session boolean required Runs must reference a saved session of this app. timeout_seconds integer required Run timeout used when the request gives none. tags array[string] required 401 Unauthorized error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional GET /api/v1/tools/{tool_name} ------------------------------ Get a tool Tool metadata including the JSON Schemas of its input ('params') and output ('result'). Parameters: tool_name (path, required) string Responses: 200 OK name string required Unique tool identifier. example: "web.page_snapshot" app string required title string required description string required needs_browser boolean required requires_session boolean required Runs must reference a saved session of this app. timeout_seconds integer required Run timeout used when the request gives none. tags array[string] required input_schema object required JSON Schema of the run 'params'. output_schema object required JSON Schema of the run 'result'. 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional POST /api/v1/runs ------------------ Start a run Queue a tool execution. Runs are asynchronous: this answers '202' with the queued run, to be polled at 'GET /runs/{run_id}'. With 'wait_seconds' the call blocks until the run finishes and answers '200'; if it is still going after that long you get the usual '202'. Parameters: wait_seconds (query, optional) number Hold the request up to this long for the run to finish. '0' returns immediately. Request body (JSON): tool string required Tool to execute. example: "web.page_snapshot" params object optional Tool input; validated against the tool's 'input_schema'. example: {"url": "https://example.com"} client_request_id string | null optional Your own id for this request, echoed back and filterable at 'GET /runs?client_request_id=...', so you can match results to the requests you sent. The run also always gets a separate random 'id' of its own. example: "order-4821" session_id string | null optional Saved session to run as (must belong to the tool's app). browser BrowserOverrides | null optional timeout_seconds integer | null optional Responses: 202 Accepted id string required client_request_id string | null required tool string required app string required status RunStatus required session_id string | null required cancel_requested boolean required error RunError | null required created_at string required started_at string | null required finished_at string | null required params object required result object | null required Tool output, once the run succeeded. browser BrowserOverrides | null required timeout_seconds integer required artifacts array[ArtifactRead] required duration_seconds number | null required 401 Unauthorized error ErrorBody required 200 OK id string required client_request_id string | null required tool string required app string required status RunStatus required session_id string | null required cancel_requested boolean required error RunError | null required created_at string required started_at string | null required finished_at string | null required params object required result object | null required Tool output, once the run succeeded. browser BrowserOverrides | null required timeout_seconds integer required artifacts array[ArtifactRead] required duration_seconds number | null required 404 Not Found error ErrorBody required 422 Unprocessable Content error ErrorBody required GET /api/v1/runs ----------------- List runs Newest first. Parameters: status (query, optional) RunStatus | null tool (query, optional) string | null app (query, optional) string | null client_request_id (query, optional) string | null Only runs you tagged with this id. limit (query, optional) integer Page size. offset (query, optional) integer Items to skip. Responses: 200 OK items array[RunSummary] required total integer required Number of items matching the filters, ignoring pagination. limit integer required offset integer required 401 Unauthorized error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional GET /api/v1/runs/{run_id} -------------------------- Get a run Status, result or error, and artifacts of a run. Parameters: run_id (path, required) string Responses: 200 OK id string required client_request_id string | null required tool string required app string required status RunStatus required session_id string | null required cancel_requested boolean required error RunError | null required created_at string required started_at string | null required finished_at string | null required params object required result object | null required Tool output, once the run succeeded. browser BrowserOverrides | null required timeout_seconds integer required artifacts array[ArtifactRead] required duration_seconds number | null required 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional POST /api/v1/runs/{run_id}/cancel ---------------------------------- Cancel a run A queued run is cancelled immediately. A running one gets 'cancel_requested' and turns 'cancelled' once its worker has stopped it, a few seconds later. Parameters: run_id (path, required) string Responses: 200 OK id string required client_request_id string | null required tool string required app string required status RunStatus required session_id string | null required cancel_requested boolean required error RunError | null required created_at string required started_at string | null required finished_at string | null required params object required result object | null required Tool output, once the run succeeded. browser BrowserOverrides | null required timeout_seconds integer required artifacts array[ArtifactRead] required duration_seconds number | null required 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 409 Conflict error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional GET /api/v1/runs/{run_id}/artifacts ------------------------------------ List the artifacts of a run Parameters: run_id (path, required) string Responses: 200 OK array of: ArtifactRead id string required run_id string required name string required kind ArtifactKind required content_type string required size_bytes integer required created_at string required download_url string required 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional GET /api/v1/runs/{run_id}/artifacts/{artifact_id} -------------------------------------------------- Download an artifact Parameters: run_id (path, required) string artifact_id (path, required) string Responses: 200 OK (application/octet-stream) 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional POST /api/v1/sessions ---------------------- Save a session Store a logged-in browser state for one account of an app. Produce the 'storage_state' by logging in once by hand, e.g. 'playwright codegen --save-storage=state.json https://the-app.example'. Runs that pass the returned 'id' as 'session_id' start already signed in. Request body (JSON): app string required (max length: 100) example: "web" name string required Label of the account, unique per app. (min length: 1) (max length: 100) example: "personal" storage_state StorageState optional Playwright storage state, as written by 'context.storage_state()' or 'playwright codegen --save-storage=state.json'. Responses: 201 Created id string required app string required name string required cookies integer required Number of stored cookies. origins integer required Number of origins with stored localStorage. created_at string required updated_at string required last_used_at string | null required 401 Unauthorized error ErrorBody required 409 Conflict error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional GET /api/v1/sessions --------------------- List sessions Parameters: app (query, optional) string | null Only sessions of this app. limit (query, optional) integer Page size. offset (query, optional) integer Items to skip. Responses: 200 OK items array[SessionRead] required total integer required Number of items matching the filters, ignoring pagination. limit integer required offset integer required 401 Unauthorized error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional GET /api/v1/sessions/{session_id} ---------------------------------- Get a session Parameters: session_id (path, required) string Responses: 200 OK id string required app string required name string required cookies integer required Number of stored cookies. origins integer required Number of origins with stored localStorage. created_at string required updated_at string required last_used_at string | null required 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional DELETE /api/v1/sessions/{session_id} ------------------------------------- Delete a session Parameters: session_id (path, required) string Responses: 204 No Content 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional PUT /api/v1/sessions/{session_id}/storage-state ------------------------------------------------ Replace the stored login Use this after logging in again when the saved login has expired. Parameters: session_id (path, required) string Request body (JSON): cookies array[object] optional origins array[object] optional Responses: 200 OK id string required app string required name string required cookies integer required Number of stored cookies. origins integer required Number of origins with stored localStorage. created_at string required updated_at string required last_used_at string | null required 401 Unauthorized error ErrorBody required 404 Not Found error ErrorBody required 422 Unprocessable Content detail array[ValidationError] optional ====================================================================================== 6. REQUEST/RESPONSE SCHEMAS (FULL FIELD REFERENCE) ====================================================================================== Full definitions of every named schema referenced above. 'Page_*' are the generic paginated-list wrapper, specialised per item type. AppRead ------- name string required Identifier; prefixes its tools and scopes its sessions. title string required description string required base_url string | null required verifies_login boolean required Runs of tools that require a session first check that the login is still valid, and fail with 'session_expired' when it is not. tools integer required Number of tools available for this app. ArtifactKind ------------ enum: 'screenshot', 'trace', 'video', 'file' ArtifactRead ------------ id string required run_id string required name string required kind ArtifactKind required content_type string required size_bytes integer required created_at string required download_url string required BrowserOverrides ---------------- Per-run overrides. Endpoints (CDP url, remote server) are deliberately not overridable. mode 'launch' | 'persistent' | 'cdp' | 'remote' | null optional 'launch': fresh isolated context in a locally launched browser. 'persistent': on-disk browser profile kept between runs. 'cdp': attach to an already running Chromium. 'remote': use a Playwright server. engine 'chromium' | 'firefox' | 'webkit' | null optional headless boolean | null optional trace 'off' | 'on' | 'retain-on-failure' | null optional Record a Playwright trace (viewable with 'playwright show-trace'). video boolean | null optional Record a video of every page. ErrorBody --------- code string required Stable machine-readable error code. example: "run_not_found" message string required details any | null optional request_id string | null optional ErrorResponse ------------- Every non-2xx response has this shape. error ErrorBody required HTTPValidationError ------------------- detail array[ValidationError] optional HealthStatus ------------ status string required Page_RunSummary_ ---------------- items array[RunSummary] required total integer required Number of items matching the filters, ignoring pagination. limit integer required offset integer required Page_SessionRead_ ----------------- items array[SessionRead] required total integer required Number of items matching the filters, ignoring pagination. limit integer required offset integer required RunCreate --------- tool string required Tool to execute. example: "web.page_snapshot" params object optional Tool input; validated against the tool's 'input_schema'. example: {"url": "https://example.com"} client_request_id string | null optional Your own id for this request, echoed back and filterable at 'GET /runs?client_request_id=...', so you can match results to the requests you sent. The run also always gets a separate random 'id' of its own. example: "order-4821" session_id string | null optional Saved session to run as (must belong to the tool's app). browser BrowserOverrides | null optional timeout_seconds integer | null optional RunDetail --------- id string required client_request_id string | null required tool string required app string required status RunStatus required session_id string | null required cancel_requested boolean required error RunError | null required created_at string required started_at string | null required finished_at string | null required params object required result object | null required Tool output, once the run succeeded. browser BrowserOverrides | null required timeout_seconds integer required artifacts array[ArtifactRead] required duration_seconds number | null required RunError -------- code string required example: "timeout" message string required type string | null optional Exception class, for unexpected errors. RunStatus --------- enum: 'queued', 'running', 'succeeded', 'failed', 'cancelled' RunSummary ---------- id string required client_request_id string | null required tool string required app string required status RunStatus required session_id string | null required cancel_requested boolean required error RunError | null required created_at string required started_at string | null required finished_at string | null required duration_seconds number | null required SessionCreate ------------- app string required (max length: 100) example: "web" name string required Label of the account, unique per app. (min length: 1) (max length: 100) example: "personal" storage_state StorageState optional Playwright storage state, as written by 'context.storage_state()' or 'playwright codegen --save-storage=state.json'. SessionRead ----------- A saved session. The storage state itself is write-only. id string required app string required name string required cookies integer required Number of stored cookies. origins integer required Number of origins with stored localStorage. created_at string required updated_at string required last_used_at string | null required StorageState ------------ Playwright storage state, as written by 'context.storage_state()' or 'playwright codegen --save-storage=state.json'. cookies array[object] optional origins array[object] optional ToolDetail ---------- name string required Unique tool identifier. example: "web.page_snapshot" app string required title string required description string required needs_browser boolean required requires_session boolean required Runs must reference a saved session of this app. timeout_seconds integer required Run timeout used when the request gives none. tags array[string] required input_schema object required JSON Schema of the run 'params'. output_schema object required JSON Schema of the run 'result'. ToolSummary ----------- name string required Unique tool identifier. example: "web.page_snapshot" app string required title string required description string required needs_browser boolean required requires_session boolean required Runs must reference a saved session of this app. timeout_seconds integer required Run timeout used when the request gives none. tags array[string] required ValidationError --------------- loc array[string | integer] required msg string required type string required input any optional ctx object optional ====================================================================================== 7. TOOL CATALOGUE ====================================================================================== Every tool currently registered, with its full input and output JSON Schema exactly as served by GET /api/v1/tools/{name}. This is the live, authoritative contract for each tool's 'params' and 'result'. New apps/tools appear here automatically next time this file is regenerated. gemini.deep_research -------------------- App: gemini Title: Deep research Send a prompt and files to Gemini with a chosen model/effort, run Deep Research (and other tools), and return the report as Markdown (stored verbatim). Needs browser: True Needs session: True Default timeout: 1800 s Tags: research, chat Input (params) prompt string required The research question / instructions. (min length: 1) (max length: 50000) files array[InputFile] optional Files to attach (base64). ≤20 MiB each, ≤50 MiB total. (max items: 10) model 'fast' | 'pro' | 'thinking' | null optional, default='pro' Model to select in the mode picker: fast | pro | thinking. null keeps the current one. effort 'low' | 'medium' | 'high' | null optional, default=None Reasoning effort for the mode picker: low | medium | high. null keeps the current one. deep_research boolean optional, default=True Enable Deep Research: confirm the research plan, wait for it to finish and open the report. When false, this is a normal prompt and the answer is returned. extra_tools array['canvas' | 'web_search' | 'image' | 'guided_learning'] optional Other composer tools to enable if available: canvas, web_search, image, guided_learning. Best effort — ones Gemini does not currently offer are reported in 'unavailable', not errors. research_timeout_seconds integer optional, default=1500 How long to wait for Deep Research / the answer to finish. (min: 30) (max: 3000) Output (result) markdown string required The full answer, exactly as Gemini produced it. chars integer required Length of the answer in characters. conversation_url string required URL of the Gemini conversation. mode string | null required The mode the picker shows after selection, if read. deep_research boolean required Whether Deep Research was engaged. applied array[string] required Settings/tools that took effect, e.g. ['model:pro', 'effort:medium', 'deep_research', 'canvas']. unavailable array[string] required Requested settings/tools whose control was not found in the current UI. artifact string required Name of the Markdown artifact attached to the run. Example request body: {"tool": "gemini.deep_research", "params": {...}} web.page_snapshot ----------------- App: web Title: Page snapshot Open a URL and return its title, visible text and a screenshot. Needs browser: True Needs session: False Default timeout: 120 s Tags: example Input (params) url string required Page to open. (min length: 1) (max length: 2083) full_page boolean optional, default=False Capture the whole scrollable page. include_text boolean optional, default=True Return the visible text of the page. max_text_chars integer optional, default=5000 (min: 0) (max: 200000) Output (result) url string required Final URL after redirects. status integer | null required HTTP status of the main document. title string required text string | null optional, default=None screenshot string required Name of the screenshot artifact attached to the run. Example request body: {"tool": "web.page_snapshot", "params": {...}} ====================================================================================== 8. APP CATALOGUE ====================================================================================== gemini ------ Title: Google Gemini Base URL: https://gemini.google.com Verifies login: True Run Gemini Deep Research with your Google account; return the report as Markdown. Full write-up: docs/apps/gemini.md web --- Title: Web Base URL: (none) Verifies login: False Generic tools for any public web page; no login involved. Full write-up: docs/apps/web.md ====================================================================================== 9. TYPICAL WORKFLOW AND EXAMPLES ====================================================================================== 9.1 Discover curl -H "X-API-Key: $KEY" https://your-host/api/v1/tools curl -H "X-API-Key: $KEY" https://your-host/api/v1/tools/web.page_snapshot 9.2 Start a run and wait for a short one curl -X POST "https://your-host/api/v1/runs?wait_seconds=30" \ -H "X-API-Key: $KEY" -H "Content-Type: application/json" \ -d '{ "tool": "web.page_snapshot", "client_request_id": "job-42", "params": {"url": "https://example.com"} }' Answers 200 with the finished run if it completed within wait_seconds (max 120), otherwise 202 with the still-running run -- then poll. 9.3 Poll a longer run curl -H "X-API-Key: $KEY" https://your-host/api/v1/runs/ Repeat every 1-2 seconds until 'status' is succeeded / failed / cancelled. 9.4 Find your own runs later, by client_request_id curl -H "X-API-Key: $KEY" \ "https://your-host/api/v1/runs?client_request_id=job-42" 9.5 Cancel curl -X POST -H "X-API-Key: $KEY" \ https://your-host/api/v1/runs//cancel 9.6 Download an artifact (e.g. a captured report, a screenshot, run.log) curl -H "X-API-Key: $KEY" -OJ \ https://your-host/api/v1/runs//artifacts/ 9.7 Save a login (session) for a tool that requires one # Export a Playwright storage state once, signed in by hand: uv run playwright codegen --save-storage=state.json https://the-app.example curl -X POST https://your-host/api/v1/sessions \ -H "X-API-Key: $KEY" -H "Content-Type: application/json" \ -d "{\"app\": \"gemini\", \"name\": \"personal\", \"storage_state\": $(cat state.json)}" 9.8 Minimal Python client import time, httpx api = httpx.Client(base_url="https://your-host/api/v1", headers={"X-API-Key": "..."}) def run_tool(tool, params, session_id=None, timeout=600): r = api.post("/runs", json={"tool": tool, "params": params, "session_id": session_id}) r.raise_for_status() run_id, deadline = r.json()["id"], time.monotonic() + timeout while time.monotonic() < deadline: body = api.get(f"/runs/{run_id}").json() status = body["status"] if status == "succeeded": return body["result"] if status in ("failed", "cancelled"): raise RuntimeError(f"{tool} {status}: {body['error']}") time.sleep(1.5) api.post(f"/runs/{run_id}/cancel") raise TimeoutError(f"{tool} did not finish within {timeout}s") ====================================================================================== 10. OBSERVABILITY: LOGS AND THE RUN.LOG ARTIFACT ====================================================================================== Every run produces structured, correlated logs: all lines emitted while it executes carry its run_id, tool, app, client_request_id and worker_id. When RUN_LOG_CAPTURE is enabled (the default), the full step-by-step trace of a single run is also attached to it as a 'run.log' artifact (JSON Lines, one event per line) -- download it the same way as any other artifact (section 9.6). A failed or slow run is usually best understood by reading its run.log, its Playwright trace ('trace.zip', open with 'uv run playwright show-trace trace.zip'), and its failure screenshot, together. Full reference: docs/logging.md. ###################################################################################### END OF DOCUMENT ######################################################################################