<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>中间件 :: 标签 :: x7peeps</title><link>https://x7peeps.com/tags/%E4%B8%AD%E9%97%B4%E4%BB%B6/index.html</link><description/><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Mon, 17 Aug 2026 08:35:59 +0000</lastBuildDate><atom:link href="https://x7peeps.com/tags/%E4%B8%AD%E9%97%B4%E4%BB%B6/index.xml" rel="self" type="application/rss+xml"/><item><title>补充emit_waterfall中间件分发特性的研究</title><link>https://x7peeps.com/%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE/hermes%E6%96%B0%E7%89%B9%E6%80%A7/%E8%A1%A5%E5%85%85emit_waterfall%E4%B8%AD%E9%97%B4%E4%BB%B6%E5%88%86%E5%8F%91%E7%89%B9%E6%80%A7%E7%9A%84%E7%A0%94%E7%A9%B6/index.html</link><pubDate>Mon, 17 Aug 2026 08:35:59 +0000</pubDate><guid>https://x7peeps.com/%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE/hermes%E6%96%B0%E7%89%B9%E6%80%A7/%E8%A1%A5%E5%85%85emit_waterfall%E4%B8%AD%E9%97%B4%E4%BB%B6%E5%88%86%E5%8F%91%E7%89%B9%E6%80%A7%E7%9A%84%E7%A0%94%E7%A9%B6/index.html</guid><description>PR 地址：NousResearch/hermes-agent#85370 · 为 gateway 事件钩子增加 Cordis 风格 around-middleware 分发模式 emit_waterfall
研究摘要 之前，Hermes gateway 的钩子只有两种扁平扇出模式：emit（观察，handler 返回值被忽略）与 emit_collect（收集，返回值由调用方统一解读）。任何 handler 都无法在下游 handler 看到值之前改写它，也无法终止链条——一个 deny 决策挡不住后面的 handler 继续执行。命令分发路径靠返回 {"decision": ...} 字典、再到 gateway/run.py 里重新解读来绕，但这种模式表达不了"前一个 handler 重写了命令、现在对重写后的命令重新检查"。现在，HookRegistry.emit_waterfall() 提供真正的中间件链：handler 收到 next_fn，调用 await next_fn(new_value=...) 委托下游（可替换值），不调用直接返回即短路，handler 的返回值成为瀑布结果。</description></item></channel></rss>