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

# Streaming

# Streaming & Events

Svantic supports real-time streaming via the A2A protocol's SSE (Server-Sent Events) mechanism, enabling clients to receive progressive updates as tasks execute.

***

## A2A Streaming

When a client sends a task to Svantic via `message/stream`, the response is an SSE stream of A2A events:

<img src="https://mintcdn.com/svantic/DQEVJ_RnVW5_l6gu/images/diagrams/streaming-sequence.svg?fit=max&auto=format&n=DQEVJ_RnVW5_l6gu&q=85&s=fadebafd09edb099989b4f178a79f08e" alt="A2A streaming sequence: client sends message/stream, receives SSE events for status updates, messages, artifacts, and completion" width="680" height="380" data-path="images/diagrams/streaming-sequence.svg" />

## Event Types

### TaskStatusUpdateEvent

Reports task lifecycle changes:

| State            | Meaning                                 |
| ---------------- | --------------------------------------- |
| `submitted`      | Task received, queued for processing    |
| `working`        | Execution in progress                   |
| `input-required` | Waiting for user input (form, approval) |
| `completed`      | Task finished successfully              |
| `failed`         | Task failed with error                  |
| `canceled`       | Task was canceled                       |

### Message

An agent response containing one or more `Part`s:

| Part Kind  | Content                                                       |
| ---------- | ------------------------------------------------------------- |
| `TextPart` | Plain text (thoughts, explanations, answers)                  |
| `DataPart` | Structured JSON (tool results, forms, capability invocations) |
| `FilePart` | File content or reference                                     |

### TaskArtifactUpdateEvent

Emitted when the agent produces a tangible output — a file, a structured document, or a final result.

***

## Consuming Streams

### Using RemoteAgent (SDK)

```typescript theme={null}
import { RemoteAgent } from '@svantic/sdk';

const remote = await RemoteAgent.connect('http://savant:3000');
const stream = remote.send_stream('Analyze this codebase', 'session-1');

for await (const event of stream) {
    if (event.kind === 'status-update') {
        console.log('Status:', event.status.state);
    }
    if (event.kind === 'message') {
        for (const part of event.message.parts) {
            if (part.kind === 'text') {
                process.stdout.write(part.text);
            }
        }
    }
}
```

### Using the REST API

For direct HTTP access, use `POST /send` with `method: "message/stream"` — see the [Using the API guide](../guides/using-the-api).

***

## Event Conversion

Svantic's internal engine events are automatically converted to A2A events by the `EventConverter`:

| Internal Event        | A2A Event                               |
| --------------------- | --------------------------------------- |
| Agent text output     | `Message` with `TextPart`               |
| Tool call start       | `TaskStatusUpdateEvent` (working)       |
| Tool result           | `Message` with `DataPart`               |
| Plan approval request | `Message` with `DataPart` (form)        |
| A2UI form             | `Message` with `DataPart` (form fields) |
| Execution complete    | `TaskStatusUpdateEvent` (completed)     |
| Error                 | `TaskStatusUpdateEvent` (failed)        |
