Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,272 changes: 5,272 additions & 0 deletions _verify_owui/middleware.py

Large diffs are not rendered by default.

1,095 changes: 1,095 additions & 0 deletions _verify_owui/misc.py

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions plugins/filters/async-context-compression/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Async Context Compression Filter

| By [Fu-Jie](https://github.com/Fu-Jie) · v1.7.2 | [⭐ Star this repo](https://github.com/Fu-Jie/openwebui-extensions) |
| By [Fu-Jie](https://github.com/Fu-Jie) · v1.7.3 | [⭐ Star this repo](https://github.com/Fu-Jie/openwebui-extensions) |
| :--- | ---: |

| ![followers](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_followers.json&label=%F0%9F%91%A5&style=flat) | ![points](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_points.json&label=%E2%AD%90&style=flat) | ![top](https://img.shields.io/badge/%F0%9F%8F%86-Top%20%3C1%25-10b981?style=flat) | ![contributions](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_contributions.json&label=%F0%9F%93%A6&style=flat) | ![downloads](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_downloads.json&label=%E2%AC%87%EF%B8%8F&style=flat) | ![saves](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_saves.json&label=%F0%9F%92%BE&style=flat) | ![views](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_views.json&label=%F0%9F%91%81%EF%B8%8F&style=flat) |
Expand Down Expand Up @@ -28,6 +28,15 @@ When the selection dialog opens, search for this plugin, check it, and continue.
- **Protected-head tracking**: Summary rows remember how many leading messages were kept outside the summary. If the current `keep_first` policy no longer preserves those messages, the row is not reused as branch-valid coverage.
- **Safe upgrade behavior**: Legacy summaries without coverage metadata are not trusted as coverage. The first turn after upgrading may send more raw context until a branch-valid summary row is generated.

## What's new in 1.7.3

- **Summary persistence on fresh PostgreSQL**: Fixed `DuplicateTable: relation "ix_chat_summary_chat_id" already exists` and the resulting `⚠️ Summary generated but was not persisted`. The shared SQLAlchemy metadata is now deduplicated before `CREATE TABLE`, and legacy colliding indexes are cleared idempotently.
- **Outlet summary reuse for idless plain-chat branches**: When the outlet request carries a `chat_id` but no stable message refs, the filter now reads the active DB branch and aligns the body against it so the generated summary can be persisted and reused on subsequent turns.
- **Reasoning-model inlet reuse (issue #98)**: Reasoning models store folded `<details type="reasoning">` content in the DB, but the request body reconstructed by `process_messages_with_output` strips or re-tags the reasoning, so cached summaries were rejected every turn. A new position-based fallback (Path 3) accepts the snapshot when body and DB branches have equal length and roles / tool_calls / tool_call_id match position-by-position. DB messages with an `output` array are exempted from content comparison; DB messages without `output` still require exact content equality, so edited or tampered bodies are rejected.
- **Path 3 mixed-id fix**: `process_messages_with_output` only strips `output` (not `id`), so real reasoning-chat bodies are mixed-id — the all-idless guard was removed; Path 3 now accepts real reasoning chats.
- **Path 3 diagnostic logging**: when Path 3 is eligible but a per-position check fails, `debug_mode` now logs the first failing index and the mismatched field (role / tool_calls / tool_call_id / content), so silent rejections are observable.
- **End-to-end verification**: A new test module inlines `convert_output_to_messages`, `process_messages_with_output`, and `reconcile_tool_pairs` copied verbatim from the OpenWebUI main branch, and replays OpenAI-compatible / Ollama / llama.cpp / tool-call reasoning chats through the full `inlet()` entry point. The body builder mirrors the real pipeline exactly (genuinely mixed-id), with regression tests covering the mixed-id shape and Path 3 acceptance.

## What's new in 1.7.2

- **Summary injection safety guard**: Injected summaries now explicitly state that goals, open loops, and tool state inside the summary are historical context only, not new instructions.
Expand Down Expand Up @@ -221,6 +230,6 @@ If this plugin has been useful, a star on [OpenWebUI Extensions](https://github.

## Changelog

See [`v1.7.2` Release Notes](https://github.com/Fu-Jie/openwebui-extensions/blob/main/plugins/filters/async-context-compression/v1.7.2.md) for the release-specific summary.
See [`v1.7.3` Release Notes](https://github.com/Fu-Jie/openwebui-extensions/blob/main/plugins/filters/async-context-compression/v1.7.3.md) for the release-specific summary.

See the full history on GitHub: [OpenWebUI Extensions](https://github.com/Fu-Jie/openwebui-extensions)
13 changes: 11 additions & 2 deletions plugins/filters/async-context-compression/README_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 异步上下文压缩过滤器

| 作者:[Fu-Jie](https://github.com/Fu-Jie) · v1.7.2 | [⭐ 点个 Star 支持项目](https://github.com/Fu-Jie/openwebui-extensions) |
| 作者:[Fu-Jie](https://github.com/Fu-Jie) · v1.7.3 | [⭐ 点个 Star 支持项目](https://github.com/Fu-Jie/openwebui-extensions) |
| :--- | ---: |

| ![followers](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_followers.json&label=%F0%9F%91%A5&style=flat) | ![points](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_points.json&label=%E2%AD%90&style=flat) | ![top](https://img.shields.io/badge/%F0%9F%8F%86-Top%20%3C1%25-10b981?style=flat) | ![contributions](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_contributions.json&label=%F0%9F%93%A6&style=flat) | ![downloads](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_downloads.json&label=%E2%AC%87%EF%B8%8F&style=flat) | ![saves](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_saves.json&label=%F0%9F%92%BE&style=flat) | ![views](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FFu-Jie%2Fdb3d95687075a880af6f1fba76d679c6%2Fraw%2Fbadge_views.json&label=%F0%9F%91%81%EF%B8%8F&style=flat) |
Expand Down Expand Up @@ -30,6 +30,15 @@
- **受保护头部追踪**:摘要行会记录有多少开头消息是在摘要之外按原文保留的。如果当前 `keep_first` 策略已经不再保留这些消息,该摘要行不会作为 branch-valid 覆盖范围复用。
- **安全升级行为**:没有覆盖范围元数据的 legacy summary 不再被当成可信覆盖。升级后的第一轮对话可能会发送更多原始上下文,直到生成 branch-valid 摘要行。

## 1.7.3 版本更新

- **新 PostgreSQL 上的 summary 持久化**:修复了 `DuplicateTable: relation "ix_chat_summary_chat_id" already exists` 以及随之出现的 `⚠️ Summary generated but was not persisted`。`CREATE TABLE` 之前会先对共享的 SQLAlchemy metadata 做索引去重,并幂等清理撞名的 legacy 索引。
- **无 id 普通对话分支的 outlet summary 复用**:当 outlet 请求带 `chat_id` 但没有稳定 message refs 时,插件现在会读取数据库里的 active branch 并对齐 body,使生成的 summary 可以持久化并在后续轮次复用。
- **Reasoning model 的 inlet 复用(issue #98)**:Reasoning model 在数据库里保存带折叠 `<details type="reasoning">` 的 content,但 `process_messages_with_output` 重建请求 body 时会剥离或改写 reasoning,导致缓存的 summary 每轮都被拒绝。新增的 position-based 兜底路径(Path 3)在 body 与 DB 分支长度相同、role / tool_calls / tool_call_id 按位置匹配时接受 snapshot。带 `output` 数组的 DB 消息豁免 content 比对;没有 `output` 的 DB 消息仍要求 content 精确匹配,因此被编辑或篡改的 body 会被拒绝。
- **Path 3 混合 id 修复**:`process_messages_with_output` 只剥离 `output`(不剥离 `id`),真实 reasoning 对话的 body 是混合 id 的——all-idless 守卫已移除,Path 3 现在能接受真实 reasoning 对话。
- **Path 3 诊断日志**:当 Path 3 满足条件但某个位置检查失败时,`debug_mode` 现在会记录第一个失败的位置索引和不匹配的字段(role / tool_calls / tool_call_id / content),让静默拒绝变得可见。
- **端到端验证**:新增测试模块内联了从 OpenWebUI main 分支逐行复制的 `convert_output_to_messages`、`process_messages_with_output` 和 `reconcile_tool_pairs`,并对 OpenAI 兼容 / Ollama / llama.cpp / 带 tool_calls 的 reasoning 对话走完整 `inlet()` 入口进行回放验证。body 构造精确镜像真实管道(真正的混合 id),回归测试覆盖混合 id 形状和 Path 3 接受。

## 1.7.2 版本更新

- **摘要注入安全边界**:注入给模型的 summary 现在会明确说明,summary 里的目标、待办和工具状态只代表历史上下文,不是新的指令。
Expand Down Expand Up @@ -262,6 +271,6 @@ flowchart TD

## 更新日志

请查看 [`v1.7.2` 版本发布说明](https://github.com/Fu-Jie/openwebui-extensions/blob/main/plugins/filters/async-context-compression/v1.7.2_CN.md) 获取本次版本的独立发布摘要。
请查看 [`v1.7.3` 版本发布说明](https://github.com/Fu-Jie/openwebui-extensions/blob/main/plugins/filters/async-context-compression/v1.7.3_CN.md) 获取本次版本的独立发布摘要。

完整历史请查看 GitHub 项目: [OpenWebUI Extensions](https://github.com/Fu-Jie/openwebui-extensions)
Loading
Loading