Class: StreamEmitter
Methods
emit()
Emit a raw stream event to the host. Parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
event_type | str | Yes | Event type identifier |
data | dict | str | Yes | Event payload (dict serialized to JSON, or string) |
progress()
Emit adata-tool-progress event for UI progress display.
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
content | str | Yes | - | Progress message |
tool_name | str | None | No | None | Tool identifier for grouping |
intent()
Emit adata-intent event for high-level state changes.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
content | str | Yes | Intent description |
Common Usage Patterns
Phase-Based Progress
Intent for State Changes
Tool-Associated Progress
Fallback When Unavailable
ctx.stream is always present. It is a safe no-op in test contexts:
Emission During LLM Calls
Progress emits are fire-and-forget over NATS - they do not block:Event Types
Standard types used by Friday:| Type | Usage |
|---|---|
data-tool-progress | Agent progress updates (use progress()) |
data-intent | High-level state changes (use intent()) |
data-error | Error events (usually emitted by host) |
emit() but may not have UI handlers.
Best Practices
- Emit before expensive operations - Warn users before long LLM calls
- Use tool_name for grouping - Helps UI organise progress by component
- Keep messages concise - 50-100 characters ideal for UI display
- Avoid tight loop emission - Batch or debounce high-frequency updates
- Prefer intent for phases, progress for detail - Two-level hierarchy
- Always safe to call -
ctx.streamnever None, but may no-op in tests
When to Emit
| Scenario | Method | Example |
|---|---|---|
| Starting a phase | intent() | ”Analysing repository” |
| Detailed progress | progress() | ”Fetching 50 files…” |
| Tool-specific work | progress(tool_name=...) | tool_name=“GitHub” |
| Fallback scenarios | progress() | ”Retrying with alternate model…” |
| Completion | intent() | ”Analysis complete” |
See Also
How to Stream Progress
Task-oriented guide
How Agents Work
The subprocess model and host capabilities

