Flows category icon
Agent Architecture
Intermediate

Streaming and Partial-Result UX

Stream model output and tool progress so users see the agent think and act - the UX baseline every serious terminal agent has set.

4 steps12 verify checks60-90 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/4 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
My agent goes silent for 30-90 seconds and users assume it is broken. Terminal agents like opencode won users by streaming tokens, showing tool activity live, and making long work feel alive and interruptible.

GOAL:
Add end-to-end streaming: token streaming from the model, live tool-activity events, and graceful partial results on interruption.

REQUIREMENTS:
- Token-level streaming of model text to the client (SSE or websocket)
- Tool lifecycle events streamed: started, result summary, failed
- A structured event protocol with types, not raw text splicing
- Interruption support: cancel mid-run and receive a coherent partial result
- Graceful rendering of interleaved text and tool activity

CONSTRAINTS:
- The event protocol must be versioned and typed - clients should not parse prose
- Interruption must leave state consistent (no half-applied edits)

DEFINITION OF DONE:
- First token reaches the client in under 2 seconds on a normal run
- Tool calls appear as live activity lines with running/success/failure states
- Cancel mid-generation yields a partial transcript plus a clean run state
- A slow 60-second task shows continuous signs of life throughout

COMMON FAILURES TO AVOID:
- Buffering the entire response and calling a spinner 'streaming'
- Interleaving raw tool JSON into the text stream and breaking the client
- Cancellation that kills the process but leaves files half-edited
- No heartbeat during long tool runs so users still think it froze

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More Agent Architecture flows that share ground with this one.

Flows category icon
Agent Architecture

Add a Plan/Todo System to Your Agent

Give your agent the planning discipline of the leading harnesses: an explicit, model-visible todo list that survives long tasks.

01Design the todo data model and tool
02Render the plan into context every turn
03Enforce plan-first and completion gates

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps60-90 minutesIntermediate
Flows category icon
Agent Architecture

Agent-to-Agent Protocols (A2A)

Connect two agents over an explicit protocol - task handoff, acknowledgment, and failure handling - instead of hoping chat works out.

01Define the protocol
02Build the message layer
03Wrap agents as protocol endpoints

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-150 minutesAdvanced
Flows category icon
Agent Architecture

Assemble a System Prompt Like the Pros

Structure your agent's system prompt the way leading harnesses do: layered sections, dynamic context, and enforceable rules.

01Decompose the current prompt
02Build the section-based assembler
03Pair rules with enforcement

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps60-90 minutesIntermediate

Made with Emergent