Skip to main content

Class: StreamEmitter

Methods

emit()

Emit a raw stream event to the host. Parameters: Example:

progress()

Emit a data-tool-progress event for UI progress display. Parameters: Example:

intent()

Emit a data-intent event for high-level state changes. Parameters: Example:

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:
The host may emit its own progress events during the suspension.

Event Types

Standard types used by Friday: Custom types can be emitted via 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.stream never None, but may no-op in tests

When to Emit

See Also

How to Stream Progress

Task-oriented guide

How Agents Work

The subprocess model and host capabilities