Understudy Labs Runs API

The Runs API from Understudy Labs — 2 operation(s) for runs.

OpenAPI Specification

understudy-labs-runs-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Understudy Desktop Agent Capabilities Runs API
  version: 2.2.0
  description: Authenticated loopback API for agents operating a running Understudy Desktop app. The desktop capability file supplies the ephemeral base URL and bearer token. Prompts, images, traces, and model outputs remain local unless a caller explicitly selects a remote route.
servers:
- url: http://127.0.0.1:{port}
  description: Discovered from the private desktop capability file
  variables:
    port:
      default: '17790'
security:
- desktopBearer: []
tags:
- name: Runs
paths:
  /v1/runs/{run_id}/cancel:
    post:
      operationId: cancelConversationRun
      summary: Cancel one exact active run
      parameters:
      - $ref: '#/components/parameters/RunId'
      responses:
        '200':
          description: Cancellation was requested for the exact run
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
      tags:
      - Runs
  /v1/runs/{run_id}/events:
    get:
      operationId: conversationRunEvents
      summary: Replay the immutable canonical trace for one exact run
      parameters:
      - $ref: '#/components/parameters/RunId'
      responses:
        '200':
          description: Persisted RuntimeEventEnvelope records in sequence order
          content:
            application/x-ndjson:
              schema:
                $ref: '#/components/schemas/RuntimeEventEnvelope'
              x-understudy-stream-item: true
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
      tags:
      - Runs
components:
  schemas:
    ErrorResponse:
      type: string
      description: A bounded plain-text error. Clients must not treat it as model output.
    RuntimeEventEnvelope:
      type: object
      required:
      - schema_version
      - event_id
      - run_id
      - session_id
      - runtime_id
      - sequence
      - emitted_at
      - event
      - data
      properties:
        schema_version:
          const: understudy-conversation-runtime-event-v1
        event_id:
          type: string
          minLength: 1
        run_id:
          $ref: '#/components/schemas/AgentId'
        session_id:
          $ref: '#/components/schemas/AgentId'
        runtime_id:
          type: string
          minLength: 1
        sequence:
          type: integer
          minimum: 0
        emitted_at:
          type: string
          format: date-time
        event:
          type: string
          enum:
          - message
          - delta
          - reasoning_delta
          - tool_call
          - tool_result
          - usage
          - supervisor_verdict
          - student_interruption
          - teacher_continuation
          - cancellation
          - error
          - image_attachment
          - compaction_boundary
        data:
          type: object
          additionalProperties: true
      additionalProperties: false
    CancelResponse:
      type: object
      required:
      - ok
      - status
      - run_id
      properties:
        ok:
          const: true
        status:
          const: cancelling
        run_id:
          $ref: '#/components/schemas/AgentId'
      additionalProperties: false
    AgentId:
      type: string
      minLength: 1
      maxLength: 200
      pattern: ^[A-Za-z0-9._:-]+$
  responses:
    Unauthorized:
      description: Missing or invalid desktop bearer token
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: The requested run or trace was not found
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  parameters:
    RunId:
      name: run_id
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/AgentId'
  securitySchemes:
    desktopBearer:
      type: http
      scheme: bearer
      description: Ephemeral token read from the owner-only desktop capability file. Agents should use the Understudy CLI or MCP adapter instead of printing this token.
x-understudy-discovery:
  capability_file: ~/.understudy/desktop-api.json
  capability_schema: understudy.desktop_api.v2
  required_file_mode: '0600'
  recommended_adapter: understudy desktop
x-understudy-extension-surfaces:
  available_via_versioned_rest_mcp_and_cli:
  - runtime status
  - model inventory and certified catalog
  - model download lifecycle
  - residency slot lifecycle
  - local correction-pair export and supervision metrics
  not_yet_versioned_in_v2_rest:
  - conversation inspect, branch, compact, and resume
  - runtime and CLI diagnostics with repair actions
  - general capture export outside desktop supervision
  - resumable desktop-wide event subscription