---
title: "Stream Agent Logs"
method: GET
path: "/logs/stream"
tags: ["Logs"]
---

# Stream Agent Logs

`GET /logs/stream`

Stream logs for an agent in real-time using Server-Sent Events (SSE). Emits multiple event types (connected, log, error) discriminated by 'type' field. Only streams NEW logs after connection (like tail -f). Auto-disconnects after 5 minutes for cost control.

## Query parameters

- `agent_name` string, required — Name of the agent (format: namespace/name or agent ID)
- `task_id` string, nullable — Filter by task ID
- `level` 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL' — Log level for entries.
- `source` 'stdout' | 'stderr' | 'server' — Source of the log entry.
- `branch_id` string, nullable — Filter by branch/version ID

## Response `200`

SSE stream of log events

- union — Union of all possible log stream SSE events. Use the 'type' field to discriminate between event types: - "connected": Stream connection established - "log": A log entry - "error": An error occurred in the stream
  - LogStreamConnectedEvent — Sent when SSE log stream connection is established. Indicates the client is now subscribed and will receive new logs. Only logs generated AFTER this event will be streamed (tail -f behavior).
    - `agent_id` string, required — Agent ID this stream is subscribed to
    - `type` 'connected'
  - LogStreamLogEvent — A log entry in the SSE stream. Wraps LogQueryEntry fields with a type discriminator for SDK parsing.
    - `agent_id` string, required
    - `branch_id` string, nullable
    - `environment` string, nullable
    - `level` string, required
    - `log_id` string, required
    - `logger` string, nullable
    - `message` string, required
    - `source` string, required
    - `task_id` string, nullable
    - `timestamp` string, required
    - `type` 'log'
    - `version` string, nullable
  - LogStreamErrorEvent — Sent when an error occurs in the log stream. After this event, the stream may close or attempt recovery.
    - `message` string, required — Error description
    - `type` 'error'

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/terminaluse/apis/sb0-api.md) · [All operations](https://skmtc.net/terminaluse/apis/sb0-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/terminaluse/sb0-api/revisions/f24a474dc415/schema)
