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

# Stream Steps Sse

> Stream agent reasoning steps as Server-Sent Events.

Validates the thread, builds a per-request React agent, captures a
workspace snapshot, then feeds the user's message into the agent and
yields each intermediate state as a JSON SSE event. Deduplication logic
prevents re-emitting the same message twice if LangGraph yields it in
multiple stream frames. Tool messages whose envelope carries an
``artifact`` block produce a separate ``artifact`` SSE event so the
centre panel can update mid-turn.

Args:
    payload: Query text, optional thread_id, and optional runtime config.
    request: The raw HTTP request for IP logging.
    user:    The authenticated user (injected by ``require_user``).
    db:      Database session for audit logging.

Returns:
    A ``StreamingResponse`` of SSE events.



## OpenAPI

````yaml /openapi.json post /api/query/stream_steps/sse
openapi: 3.1.0
info:
  title: HAI-Co² API
  description: Human-AI Co-Construction reference implementation.
  version: 0.1.0
servers:
  - url: https://haico.gr
    description: Production
  - url: https://dev.haico.gr
    description: Development
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /api/query/stream_steps/sse:
    post:
      tags:
        - Query
      summary: Stream Steps Sse
      description: |-
        Stream agent reasoning steps as Server-Sent Events.

        Validates the thread, builds a per-request React agent, captures a
        workspace snapshot, then feeds the user's message into the agent and
        yields each intermediate state as a JSON SSE event. Deduplication logic
        prevents re-emitting the same message twice if LangGraph yields it in
        multiple stream frames. Tool messages whose envelope carries an
        ``artifact`` block produce a separate ``artifact`` SSE event so the
        centre panel can update mid-turn.

        Args:
            payload: Query text, optional thread_id, and optional runtime config.
            request: The raw HTTP request for IP logging.
            user:    The authenticated user (injected by ``require_user``).
            db:      Database session for audit logging.

        Returns:
            A ``StreamingResponse`` of SSE events.
      operationId: stream_steps_sse_api_query_stream_steps_sse_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    QueryRequest:
      properties:
        query:
          type: string
          title: Query
        thread_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Thread Id
        config:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Config
      type: object
      required:
        - query
      title: QueryRequest
      description: Payload for the SSE agent query endpoint.
    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
  securitySchemes:
    HTTPBearer:
      type: http
      description: >-
        A personal access token (`haico_pat_...`), created under Profile → API
        keys. Send it as `Authorization: Bearer <key>`. The browser session JWT
        is also accepted but is an internal mechanism and is not part of the
        public contract.
      scheme: bearer

````