agent-stream-nesting-logic

agent-stream-nesting-logic is a skill for Claude Code, Codex from UnicomAI/wanwu. It costs 63 tokens per session (921 once invoked), scanned A, original, Apache-2.0.

A technical guide for rendering nested streaming conversations in Vue 2, including main replies and child sessions created by skills, tools, or knowledge sources.

In plain words
What is it for?
Use it to attach child sessions to their parents, sort message fragments by order, separate completed Markdown blocks from active typing text, and add DOM identifiers for citation and event handling.
Why use it?
It keeps interleaved streamed content in the correct order and prevents UI flicker or lost parent-child relationships while responses are arriving.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

About the project

Wanwu is an enterprise platform for building AI agents, workflows, retrieval-augmented applications, and managing models in multi-tenant environments. It is designed for developers and enterprise teams delivering AI applications and integrations. The catalogue entries provide skills and agents for using the platform.

UnicomAI/wanwu · 2,458 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/unicomai/wanwu/agent-stream-nesting-logic
Any agent
npx skills add UnicomAI/wanwu --skill agent-stream-nesting-logic
Clone the repo
git clone --depth 1 https://github.com/UnicomAI/wanwu

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-stream-nesting-logic

README.md
[![agentmods](https://agentmods.dev/badge/skills/unicomai/wanwu/agent-stream-nesting-logic.svg)](https://agentmods.dev/skills/unicomai/wanwu/agent-stream-nesting-logic)
Your own site
<a href="https://agentmods.dev/skills/unicomai/wanwu/agent-stream-nesting-logic"><img src="https://agentmods.dev/badge/skills/unicomai/wanwu/agent-stream-nesting-logic.svg" alt="Measured on agentmods" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 921 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00063 $0.00921
Opus 5 $0.00032 $0.00461
Sonnet 5 $0.00013 $0.00184
Haiku 4.5 $0.00006 $0.00092

Measured 6d ago against content hash 8cd1dd6d70fd, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

agent-stream-nesting-logic scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/agent-stream-nesting-logic/SKILL.md · 45 lines

What it actually says

子会话递归嵌套渲染架构协议 (Nesting Architecture Protocol)

本指南针对万悟平台中「主消息 -> 子会话 (Skill/Tool/Knowledge) -> 孙级会话」的递归序列化渲染标准,定义了 AI 助手及后续维护者必须遵守的底层逻辑。

1. 核心模型:三明治序列 (The Sandwich Sequence)

为了支持正文与多个子会话(工具调用、知识库)的任意插空排列,我们不再按类型分块渲染,而是通过 messageSequence 数组实现**“三明治”交错结构**。

  • type: 'main': 文本片段。直接由 StreamProcessor 驱动打字机渲染。
  • type: 'sub': 子会话卡片。触发 SubConversion.vue 组件递归渲染。

核心映射逻辑:

  • 顶级子会话: parentId 为空的包,进入主消息的 messageSequence
  • 嵌套子会话: 具有 parentId 的包,必须由对应的父组件 ID “领养”,存入其自身的 messageSequence 中。

2. 时序法则:Order 绝对排序

  • 局部闭包排序: 在每一个 messageSequence 内部,必须以 order 字段为唯一权重进行升序排列。
  • 同 Order 追加协定: 若同一个 ID 下出现多个 Order 相同的数据包,前端视为“内容的物理追加”而非“组件的新增”。

3. 动力学:动静 Chunk 分层

在渲染 main 片段时,必须区分两种状态以防止打字时界面闪烁:

  • stableChunks: 已完成 Markdown 语法闭环解析并生成的 HTML 块集合。
  • activeResponse: 正在缓冲区排队、尚未完成闭环解析的输入文本(打字动画部分)。

4. 引用溯源:Data Attributes 协议

所有生成的子会话 DOM 必须携带以下身份锚点,以支持「引文角标点击」的事件冒泡定位:

  • data-sub-id: 该段文字所属的原子消息 ID(若是吸收片段,则为分片 ID)。
  • data-parent-id: 视觉所属的容器组件 ID(父卡片 ID)。

5. 响应式红线 (CRITICAL) - Vue 2 专供

[!IMPORTANT] 绝对禁止使用浅拷贝或快照!

在将子会话(尤其是 agentSkillText 正文分段)注册进父组件序列时,必须直接传递原始响应式对象的引用(即 parentSub.messageSequence.push(subConversion))。

  • 原因: 只有保持引用一致,外部 StreamProcessoractiveResponse 的实时增长才能无缝穿透进多层嵌套的子组件 UI 中。若使用 {...subConversion} 浅拷贝,会导致打字效果丢失或不连续。

6. 生命周期管理

  • 状态单向锁: 状态 status: 3/4(结束/失败)一旦更新,不再受后续包干扰回退。
  • ID 纠错逻辑: 若后端返回 id === parentId(自引用死循环),必须在 sseMethod.js 拦截层将其重刷 ID 为 content_ 前缀的分片包。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 45 lines · 63 tokens per session scan A 8cd1dd6d70fd

Subscribe to this mod's changes

agent-stream-nesting-logic is a skill published in the GitHub repository UnicomAI/wanwu (2,458 stars, last pushed yesterday), licensed Apache-2.0. It adds 63 tokens to every session and 921 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

dify

Use when building LLM applications with visual workflow — RAG knowledge bases, AI agents, chatbots with drag-and-drop orchestration. Dify: open-source LLM app platform supporting 30+ models (OpenAI, Claude, DeepSeek, Ollama, Qwen, GLM) with Docker deployment.

znlgis/opengis-skills · 66 tokens

Web2Skill

Convert one public website URL or an explicit batch of public URLs into a reusable skill zip backed by rendered HTML snapshots and a bounded JSONL retrieval index. Use to discover a documentation directory from one URL, crawl a supplied URL set sequentially, generate a source profile, or package indexed web content as…

zhimaAi/chatwiki · 67 tokens

Book2Skill

Convert one or more TXT, Markdown, DOCX, or PDF documents into a reusable skill zip backed by normalized Markdown, extracted images, and a grounded JSONL knowledge index. Invoke this skill before inspecting task files, then execute its workflow directly without listing directories.

zhimaAi/chatwiki · 56 tokens

agent-evaluation

Testing and benchmarking LLM agents including behavioral testing, capability assessment, reliability metrics, and production monitoring—where even top agents achieve less than 50% on real-world benc.

ranbot-ai/awesome-skills · 39 tokens

agent-orchestration-multi-agent-optimize

Optimize multi-agent systems with coordinated profiling, workload distribution, and cost-aware orchestration. Use when improving agent performance, throughput, or reliability.

ranbot-ai/awesome-skills · 38 tokens

ai-engineer

Build production-ready LLM applications, advanced RAG systems, and intelligent agents. Implements vector search, multimodal AI, agent orchestration, and enterprise AI integrations.

ranbot-ai/awesome-skills · 37 tokens