Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.powabase.ai/llms.txt

Use this file to discover all available pages before exploring further.

SSE Overview

Server-Sent Events (SSE) provide a one-directional stream from server to client over a single HTTP connection. When you call a streaming endpoint (e.g. /api/agents/{id}/run/stream), the response is a text/event-stream with individual events sent as they occur. Each event is a JSON object prefixed with ‘data: ’ on a single line, separated by blank lines.

Agent Streaming Events

EventKey FieldsDescription
startrun_id, session_idAgent run has started — save session_id for multi-turn
step_startedstepAgent is beginning a new reasoning step
chunkcontentA piece of the agent’s text response
tool_calltool_name, argumentsAgent is calling a tool with the given arguments
tool_resulttool_name, resultTool execution completed with this result
step_completedstepAgent finished a reasoning step
approval_requestedtool_name, tool_inputTool call paused — waiting for approval via the approve endpoint
completerun_idAgent run finished
errormessageAn error occurred during execution

Consuming SSE in Python

import requests
import json

response = requests.post(
    f"{BASE_URL}/api/agents/{agent_id}/run/stream",
    headers=headers,
    json={"message": "What can you help me with?"},
    stream=True,
)

for line in response.iter_lines():
    if not line:
        continue
    text = line.decode("utf-8")
    if text.startswith("data: "):
        event = json.loads(text[6:])
        event_type = event["event"]

        if event_type == "start":
            print(f"Session: {event['session_id']}")
        elif event_type == "chunk":
            print(event["content"], end="", flush=True)
        elif event_type == "tool_call":
            print(f"\n[Calling {event['tool_name']}...]")
        elif event_type == "tool_result":
            print(f"[Tool returned result]")
        elif event_type == "error":
            print(f"\nError: {event['message']}")
        elif event_type == "complete":
            print("\nDone.")

Orchestration Events

Orchestration streaming extends the agent event model with delegation events. You see the coordinator reasoning, delegating to entity agents, each entity’s response, and the coordinator’s final synthesis. Events like delegation_start and entity_chunk let you show which agent is currently working.

Workflow Streaming

Workflow streaming sends events as each block executes: block_started, block_output, block_completed, and the final workflow result. This lets you show a progress indicator for each step in a multi-block workflow.
Buffer handlingSSE data may arrive in partial chunks — a single read() call might contain half an event or multiple events. Always buffer incoming data and split on newlines to ensure you process complete events.

Next Steps

Streaming Responses Guide

Hands-on guide to consuming streaming events.

Build an Agent

Create an agent with streaming support.

Agents API Reference

Streaming endpoint documentation.