ConnectOnionConnectOnion

ui_stream

Stream agent completion summaries to WebSocket UI clients. Used with host() for real-time updates in web chat interfaces.

When an agent finishes a turn, sends a completion event to the WebSocket client: tools used, LLM calls made, total iterations.

Quick Start

main.py
1from connectonion import Agent, host 2from connectonion.useful_plugins import ui_stream 3 4agent = Agent("assistant", plugins=[ui_stream]) 5host(agent, port=8000) # WebSocket clients receive completion events

Completion event payload

Sent to the WebSocket client when each turn completes:

code
1{ 2 "type": "complete", 3 "tools_used": ["read_file", "edit", "bash"], 4 "llm_calls": 3, 5 "iterations": 3 6}

Other streaming events

Individual events are emitted directly from their sources — ui_stream only adds the final summary:

Event typeEmitted byWhen
thinkingagent.pyBefore each LLM call
tool_resulttool_executor.pyAfter each tool call
assistantagent.pyWhen agent responds
completeui_stream pluginWhen turn finishes

Does nothing when agent runs locally without a WebSocket connection (if not agent.io: return).

Events used

EventHandlerPurpose
on_completestream_completeSend completion summary to WebSocket

Enjoying ConnectOnion?

⭐ Star us on GitHub = ☕ Coffee chat with our founder. We love meeting builders.