LEAP
LEAP builds skills through two pipelines: Branch A distills a skill from raw data, while Branch B combines multiple skills into one. It is called by the main…
Enhancement-overlay decision protocol for STREAMING the output of long-running LLM / agent runs from the *backend*, not just wiring a typing animation in the UI. Activates when a coder agent must stream final tokens to a chat client, surface intermediate agent steps (which tool,
$ npx -y skills add agentsope/SkillAlchemy --skill agentsop-streaming-output --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/agentsop-streaming-outputContext preview
The summary Claude sees to decide when to auto-load this skill.
Enhancement-overlay decision protocol for STREAMING the output of long-running LLM / agent runs from the *backend*, not just wiring a typing animation in the UI. Activates when a coder agent must stream final tokens to a chat client, surface intermediate agent steps (which tool,
name: agentsop-streaming-output description: | Enhancement-overlay decision protocol for STREAMING the output of long-running LLM / agent runs from the *backend*, not just wiring a typing animation in the UI. Activates when a coder agent must stream final tokens to a chat client, surface intermediate agent steps (which tool, which node, partial reasoning), emit custom tool-progress events, choose a transport (SSE vs WebSocket), or decide what to do when the client disconnects mid-stream. The langchain / langgraph skills mention stream modes but stop at "you can stream"; this skill encodes *what to stream, over what transport, and how to fail safely*. version: 0.1.0
> Source posture: every non-trivial claim is cited inline. Short tags like > `[lg/stream]`, `[lc/astream-events]`, `[oai/stream]`, `[anthropic/stream]`, > `[mdn/sse]` resolve against `references/R1-source-evidence.md`. > > This is an **ENHANCE overlay**: it sits on top of `[[agentsop-langgraph]]` (which > names the four stream modes but treats streaming as one of ten operations) and > `[[langchain]]`. Read those for the orchestration; read this for the > streaming SOP. Cross-link: `[[agentsop-langgraph]]` OP-8.
---
Activate when **any** of these fire:
docs, multi-tool chain) and the user is **waiting** — perceived latency, not total latency, is the product metric.
"show which tool the agent is running", or "show the chain of thought".
(stream intermediate steps: node entered, tool called, partial state) OR a **long task** surface (stream custom progress like "embedded 40/200 docs").
chunked HTTP, and handle **client disconnect** / cancellation cleanly.
Anthropic `client.messages.stream` and need to know *which mode* and *what to forward to the client*.
Do **not** activate for: a single fast (<1s) completion, a batch/offline job with no waiting human, or a pure front-end animation question (that's CSS, not a backend SOP). Streaming a 300ms call adds protocol overhead for zero UX gain — see *反模式*.
---
**Stream what the user needs to *see*, not everything the engine *emits*.** A backend stream is a curated projection of the run's internal event firehose onto exactly three audiences:
1. **Chat audience → final tokens.** A human reading prose wants character-by- character output of the *final* assistant message. In LangGraph this is `stream_mode="messages"` (LLM tokens + metadata); in raw SDKs it's `stream=True` / `.messages.stream` `[lg/stream]` `[oai/stream]` `[anthropic/stream]`. They do **not** want to see tool JSON or scratch nodes.
2. **Agent audience → intermediate updates.** A developer (or a power-user UI) watching an agent work wants "entered node `planner`", "calling tool `search`", "got 5 results" — the state diffs *between* steps. LangGraph: `stream_mode="updates"` (per-node diffs) `[lg/stream]`. LangChain LCEL: `astream_events` (a typed event stream: `on_chat_model_stream`, `on_tool_start`, `on_tool_end`) `[lc/astream-events]`.
3. **Progress audience → custom events.** Work happening *inside* one tool/node (a loop, a long embed, a download) is invisible to the framework's automatic events. You must **emit** progress yourself: LangGraph `stream_mode="custom"` via `get_stream_writer()` `[lg/stream]`; LCEL via custom callback / dispatched events `[lc/astream-events]`.
The load-bearing insight from the LangGraph docs: **stream modes are composable — pass a list** (`stream_mode=["messages","updates","custom"]`) and demultiplex on the client by the tuple tag `[lg/stream]`. So the real design question is never "can I stream" but **"which projection(s) does this surface need, and how do I tag them on one wire?"**
Second axiom: **a stream is a contract with a client that can vanish.** Networks drop, users close tabs, browsers cap connections. The backend must decide, *up front*, whether a disconnect should **cancel** the run (stop burning tokens) or **detach** and let it finish (so a reconnect can replay). That decision is part of the design, not an afterthought — see *困境 Case 2*.
---
Walk top-down. Each step has a gate.
Gate: is a human **waiting** on a run that takes **>~1–2s**? If no (batch job, sub- second call), **don't stream** — return the whole payload. Streaming a fast call adds SSE/WebSocket framing, reconnect logic, and partial-parse bugs for no UX win `[mdn/sse]`. Exit here for fast paths.
Map the surface to one (or more) of the three audiences:
| Surface | Primary projection | LangGraph mode | LangChain | |---|---|---|---| | Chat / prose | final tokens | `messages` | `astream_events` → `on_chat_model_stream` | | Agent inspector / dev UI | step updates | `updates` | `astream_events` (`on_tool_*`, `on_chain_*`) | | Full-state replay / resume | snapshots | `values` | n/a (rebuild from events) | | Long in-tool work | custom progress | `custom` | dispatched custom events | | Debug everything | raw firehose | `debug` | `astream_events` (all) |
`values` emits the **full state** after each step (heavy, good for resume); `updates` emits only the **diff** (light, good for live UI) `[lg/stream]`. Default a chat agent to `["messages","updates"]` and add `"custom"` only when a tool has internal progress worth surfacing `[lg/stream]` (= `[[agentsop-langgraph]]` OP-8).
Turn people, methods, and experience into installable, reusable agent skills. SkillAlchemy is an open-world agent skill creation system that turns underspecified skill briefs and open-world sources into installable, reusable agent skills.
LEAP builds skills through two pipelines: Branch A distills a skill from raw data, while Branch B combines multiple skills into one. It is called by the main…
Lens — Add a cognitive lens to any problem. It accepts a task description and produces an enhanced description that surfaces hidden dimensions, prerequisites,…
Cross-framework enhancement overlay for choosing a multi-agent topology BEFORE writing any agent. A binary-question rubric — is single-agent + tools enough? do…
SOP for terminal-based, git-native AI pair programming with Aider (git work-tree + tree-sitter repo-map + edit-format + human-in-loop REPL). Use when editing…
Screens biomedical / life-science papers for signs of data fabrication, image manipulation, and statistical anomalies, using the detection techniques distilled…
Universal discipline for any LM-driven loop — agent retries, plan-act-observe, multi-agent handoffs, optimiser passes, test-fix cycles. Encodes the one rule…