Features
- Plugins can now run as gateway middleware with
onRequest,onEvent, andonResponsehooks to inspect or modify agent requests and responses. onRequestcan change or reject an incoming request before it is routed to the model.onEventcan filter, rewrite, or drop individual streaming events.onResponsecan inspect and modify the final response.- Middleware hooks share per-request state and can access context such as protocol, model, stream, path, agent, and plugin options.
- The Plugins page now shows a middleware badge, hook calls, average execution time, failures, and load errors.
- Added middleware documentation in English, Chinese, Japanese, and German.
Bug Fixes
- Fixed an issue where the stream sentinel
[DONE]was parsed as JSON and caused an error on every chat stream. - Fixed middleware performance stats to include JSON processing time.
Improvements
- Middleware only runs for agent traffic and does not affect internal features such as titles, classification, or stand-ins.
- If a middleware hook fails, times out, or returns an unexpected value, the request or response passes through unchanged and the failure is logged.
- Middleware files reload automatically within about a second of being changed.
- Middleware-only plugin packages are skipped by the Bun host.
Install
Download from usemagpie.ai, or curl -fsSL https://usemagpie.ai/install.sh | sh. An installed magpie updates itself.
- macOS (Apple Silicon):
magpie-darwin-arm64.dmg - macOS (Intel):
magpie-darwin-amd64.dmg - Windows:
magpie-windows-amd64.exe(ARM:magpie-windows-arm64.exe) - Linux:
magpie-linux-amd64/magpie-linux-arm64(needs GTK 3 and WebKitGTK 4.1) - Terminal only:
magpie-cli-<os>-<arch>
功能
- 插件现在可以作为网关中间件运行,并使用
onRequest、onEvent和onResponse钩子来检查或修改智能体请求与响应。 onRequest可以在传入请求被路由到模型之前更改或拒绝该请求。onEvent可以过滤、重写或丢弃单个流式事件。onResponse可以检查并修改最终响应。- 中间件钩子共享每个请求的状态,并可访问协议、模型、流、路径、智能体和插件选项等上下文。
- 插件页面现在显示中间件徽章、钩子调用次数、平均执行时间、失败和加载错误。
- 新增了英语、中文、日语和德语的中间件文档。
错误修复
- 修复了流结束标记
[DONE]被解析为 JSON 并导致每次聊天流都出错的问题。 - 修复了中间件性能统计,使其包含 JSON 处理时间。
改进
- 中间件仅对智能体流量运行,不影响标题、分类或替身等内部功能。
- 如果中间件钩子失败、超时或返回意外值,请求或响应将原样传递,并记录失败。
- 中间件文件在更改后约一秒内自动重新加载。
- 仅包含中间件的插件包会被 Bun 主机跳过。
安装
从 usemagpie.ai 下载,或运行 curl -fsSL https://usemagpie.ai/install.sh | sh。已安装的 magpie 会自动更新。