> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aegra.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Create And Stream Run

> Create a new run and stream its execution via SSE.

Returns a `text/event-stream` response with Server-Sent Events. Each
event has a `type` field (e.g. `values`, `updates`, `messages`,
`metadata`, `end`) and a JSON `data` payload.

Set `on_disconnect` to `"continue"` if the run should keep executing
after the client disconnects (default is `"cancel"`). Use `stream_mode`
to control which event types are emitted.

A periodic SSE keepalive comment is sent every
``KEEPALIVE_INTERVAL_SECS`` so idle proxies don't drop long-running
silent nodes (e.g. agents holding an upstream WebSocket).



## OpenAPI

````yaml /openapi.json post /threads/{thread_id}/runs/stream
openapi: 3.1.0
info:
  title: Aegra
  description: Production-ready Agent Protocol server
  version: 0.9.24
servers: []
security: []
tags:
  - name: Assistants
    description: A configured instance of a graph.
  - name: Threads
    description: Accumulated state and outputs from a group of runs.
  - name: Thread Runs
    description: Invoke a graph on a thread, updating its persistent state.
  - name: Stateless Runs
    description: Invoke a graph without state or memory persistence.
  - name: Crons
    description: Scheduled recurring runs on a cron schedule.
  - name: Store
    description: Persistent key-value and semantic storage available from any thread.
  - name: Event Streaming
    description: Agent Protocol v2 thread event streaming and commands.
  - name: Health
    description: Server health checks and service information.
paths:
  /threads/{thread_id}/runs/stream:
    post:
      tags:
        - Thread Runs
      summary: Create And Stream Run
      description: |-
        Create a new run and stream its execution via SSE.

        Returns a `text/event-stream` response with Server-Sent Events. Each
        event has a `type` field (e.g. `values`, `updates`, `messages`,
        `metadata`, `end`) and a JSON `data` payload.

        Set `on_disconnect` to `"continue"` if the run should keep executing
        after the client disconnects (default is `"cancel"`). Use `stream_mode`
        to control which event types are emitted.

        A periodic SSE keepalive comment is sent every
        ``KEEPALIVE_INTERVAL_SECS`` so idle proxies don't drop long-running
        silent nodes (e.g. agents holding an upstream WebSocket).
      operationId: create_and_stream_run_threads__thread_id__runs_stream_post
      parameters:
        - name: thread_id
          in: path
          required: true
          schema:
            type: string
            title: Thread Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunCreate'
      responses:
        '200':
          description: Server-Sent Events stream
          content:
            application/json:
              schema: {}
            text/event-stream:
              schema:
                type: string
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentProtocolError'
        '409':
          description: Resource state conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentProtocolError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    RunCreate:
      properties:
        assistant_id:
          type: string
          title: Assistant Id
          description: Assistant to execute
        input:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Input
          description: Input data for the run. Optional when resuming from a checkpoint.
        config:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Config
          description: Execution config
        context:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Context
          description: Execution context
        checkpoint:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Checkpoint
          description: >-
            Checkpoint configuration (e.g., {'checkpoint_id': '...',
            'checkpoint_ns': ''})
        stream:
          type: boolean
          title: Stream
          description: Enable streaming response
          default: false
        stream_mode:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Stream Mode
          description: Requested stream mode(s)
        on_disconnect:
          anyOf:
            - type: string
            - type: 'null'
          title: On Disconnect
          description: 'Behavior on client disconnect: ''cancel'' (default) or ''continue''.'
        on_completion:
          anyOf:
            - type: string
              enum:
                - delete
                - keep
            - type: 'null'
          title: On Completion
          description: >-
            Behavior after stateless run completes: 'delete' (default) removes
            the ephemeral thread, 'keep' preserves it.
        multitask_strategy:
          anyOf:
            - type: string
            - type: 'null'
          title: Multitask Strategy
          description: >-
            Strategy for handling concurrent runs on same thread: 'reject',
            'interrupt', 'rollback', or 'enqueue'.
        command:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Command
          description: >-
            Command for resuming interrupted runs with state updates or
            navigation
        interrupt_before:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Interrupt Before
          description: >-
            Nodes to interrupt immediately before they get executed. Use '*' for
            all nodes.
        interrupt_after:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Interrupt After
          description: >-
            Nodes to interrupt immediately after they get executed. Use '*' for
            all nodes.
        stream_subgraphs:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream Subgraphs
          description: >-
            Whether to include subgraph events in streaming. When True, includes
            events from all subgraphs. When False (default when None), excludes
            subgraph events. Defaults to False for backwards compatibility.
          default: false
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: >-
            Request metadata propagated to OTEL trace attributes
            (``langfuse.trace.metadata.<key>``).  Keys must match
            ``[A-Za-z0-9_-]{1,64}``.  Values must be primitive (``str``,
            ``int``, ``float``, ``bool``); string values are capped at 512
            characters.  Maximum 32 keys.  Use this for filterable attributes
            (tenant, feature flag, environment, sub-agent type) rather than
            payload data.
      type: object
      required:
        - assistant_id
      title: RunCreate
      description: Request model for creating runs
    AgentProtocolError:
      properties:
        error:
          type: string
          title: Error
          description: Error type
        message:
          type: string
          title: Message
          description: Human-readable error message
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: Additional error details
      type: object
      required:
        - error
        - message
      title: AgentProtocolError
      description: Standard Agent Protocol error response
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````