Rich progress events for real-time visibility during long-running agent tasks
Overview
Users stare at blank screens during 30+ second agent runs. The Progress Protocol provides structured events for every phase of execution — thinking, tool execution, intermediate results, and completion.
The built-in estimator calculates progress based on roundtrip count:
import { estimateProgress } from "@agentium/core";const percent = estimateProgress( 2, // current roundtrip 10, // max roundtrips "tools" // current phase: "llm" or "tools");// Returns ~25
Tool Result Previews
Generate concise previews for tool results:
import { toolResultPreview } from "@agentium/core";const preview = toolResultPreview(longToolResult, 100);// "Found 15 matching records. First result: Order #1234 placed on 2025-01-..."
Frontend Integration
Server-Sent Events (SSE)
// Server — progress events are automatically forwarded// Client:const source = new EventSource("/api/agent/stream");source.addEventListener("progress", (e) => { const event = JSON.parse(e.data); switch (event.type) { case "tool.executing": showSpinner(`Running ${event.toolName}...`); break; case "progress": updateProgressBar(event.percent); break; case "text.delta": appendText(event.text); break; }});
Socket.IO
socket.on("agent.progress", (event) => { // Same event types as SSE});