Four values. Two are emitted by every adapter, one by all four with different fidelity, and one by exactly one adapter.
Reference#
type EventType string
| Constant | Value | Meaning |
|---|---|---|
EventTextDelta | text_delta | The next fragment of assistant text, in StreamEvent.Text. The event most callers want. |
EventThinkingDelta | thinking_delta | A fragment of the model's reasoning, when the provider discloses it. Only Anthropic ever emits this. |
EventToolCall | tool_call | A completed tool call. skyl buffers partial arguments and emits this once, when the call's JSON is whole — a half-parsed tool call is not actionable. |
EventDone | done | The final event of a successful stream, carrying Usage and StopReason. |
Caveats
EventThinkingDeltais Anthropic-only. A UI driven by it stays empty on the other three.EventToolCallfires once per call, when the arguments are whole. skyl buffers the fragments for you.EventDoneis the terminal event. A stream that ends without it is reported as truncated throughStream.Err().- Provider events carrying no actionable information are dropped rather than surfaced.
Usage#
Text only, the common case
for stream.Next() {
if ev := stream.Event(); ev.Type == skyl.EventTextDelta {
fmt.Print(ev.Text)
}
}for stream.Next() {
if ev := stream.Event(); ev.Type == skyl.EventTextDelta {
fmt.Print(ev.Text)
}
}Detecting the terminal event
var sawDone bool
for stream.Next() {
if stream.Event().Type == skyl.EventDone {
sawDone = true
}
}
// Redundant in practice — Err() already reports a missing terminal event —
// but explicit if you are asserting on it in a test.
if err := stream.Err(); err != nil || !sawDone {
return fmt.Errorf("incomplete stream: %w", err)
}var sawDone bool
for stream.Next() {
if stream.Event().Type == skyl.EventDone {
sawDone = true
}
}
// Redundant in practice — Err() already reports a missing terminal event —
// but explicit if you are asserting on it in a test.
if err := stream.Err(); err != nil || !sawDone {
return fmt.Errorf("incomplete stream: %w", err)
}Troubleshooting#
Should I handle event types I do not recognise?
There are only four, and they are stable. A default branch that ignores
anything unknown is safe — skyl drops provider events that carry no actionable
information rather than passing them through as new types.