实现附件处理链路的统一引用化与可检索增强,避免大文件/多模态内容直接撑爆上下文并提升工具可用性。

本次补齐 text/image/video/archive 的标准化处理、会话级工具守卫、回放压缩、配置与文档对齐,并修复表格与流式输出相关体验问题。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-26 15:25:50 +08:00
parent 9d2900db02
commit 37a2ef35f4
27 changed files with 3227 additions and 278 deletions

View file

@ -181,6 +181,34 @@
- 作用:`tool_log` 中 args/result 截断上限
- 生效:`oclaw/platform/persistence/sqlite_store.py`
- `AIA_IMAGE_TOOL_RESULT_REPLAY_CAP_CHARS`
- 默认:`4000`
- 作用:限制历史轮次中 `query_image_attachment`(OCR/描述)结果回放到模型上下文时的 `text` 长度上限
- 范围:`600..30000`
- 优先级:DB setting(同名) > 环境变量 > `oclaw.json`(`plugins.entries.memory-wiki.auto.attachments.tabular.image_result_replay_cap_chars`) > 默认值
- 生效:`oclaw/runtime/direct_loop.py`
- `AIA_VIDEO_TOOL_RESULT_REPLAY_CAP_CHARS`
- 默认:`4000`
- 作用:限制历史轮次中 `query_video_attachment`(`task=transcript`)结果回放到模型上下文时的 `text` 长度上限
- 范围:`600..30000`
- 优先级:DB setting(同名) > 环境变量 > `oclaw.json`(`plugins.entries.memory-wiki.auto.attachments.tabular.video_result_replay_cap_chars`) > 默认值
- 生效:`oclaw/runtime/direct_loop.py`
- `video_transcript_chunk_size` / `video_transcript_chunk_overlap`(`oclaw.json` 配置项)
- 默认:`1600` / `200`
- 作用:`query_video_attachment(task=transcript)` 落库转写文本时的默认分块参数(可被工具入参覆盖)
- 范围:`size: 1..8000`,`overlap: 1..4000`(实际使用会约束 overlap < size)
- 路径:`plugins.entries.memory-wiki.auto.attachments.tabular`
- 生效:`oclaw/runtime/tools/experts/generalist/video_query.py`
- `archive_max_depth` / `archive_max_file_count` / `archive_max_entry_bytes` / `archive_max_total_uncompressed_bytes`(`oclaw.json` 配置项)
- 默认:`2` / `200` / `10485760` / `52428800`
- 作用:统一 `archive_processor`(zip/tar/tgz/gz)安全预算:限制嵌套深度、文件数量、单文件解压大小、总解压大小
- 路径:`plugins.entries.memory-wiki.auto.attachments.tabular`
- 生效:`oclaw/platform/files/archive_processor.py`, `oclaw/platform/files/file_attachments.py`
- 错误码(工具/上下文可见):`archive_unsupported_format`, `archive_path_traversal`, `archive_max_depth_exceeded`, `archive_max_file_count_exceeded`, `archive_max_entry_bytes_exceeded`, `archive_max_total_uncompressed_bytes_exceeded`, `archive_link_entry_forbidden`, `archive_special_entry_forbidden`, `archive_parse_failed`
## MCP 与工具线侧
- `AIA_MCP_SPECIALISTS`

View file

@ -57,6 +57,48 @@
---
## 2026-04-26 / Unreleased
### Added
- `AIA_IMAGE_TOOL_RESULT_REPLAY_CAP_CHARS`
- 默认值:`4000`
- 用途:限制历史轮次中 `query_image_attachment`(OCR/描述)结果回放到模型上下文时的字符上限
- 影响模块:`oclaw/runtime/direct_loop.py`, `oclaw/interfaces/admin/chat_api.py`, `oclaw/interfaces/admin/static/app.js`
- `AIA_VIDEO_TOOL_RESULT_REPLAY_CAP_CHARS`
- 默认值:`4000`
- 用途:限制历史轮次中 `query_video_attachment`(`task=transcript`)结果回放到模型上下文时的字符上限
- 影响模块:`oclaw/runtime/direct_loop.py`, `oclaw/interfaces/admin/chat_api.py`, `oclaw/interfaces/admin/static/app.js`
### Changed
- Admin「附件」设置页新增 `image_result_replay_cap_chars` 可视化配置,并写入 `oclaw.json`:
- 路径:`plugins.entries.memory-wiki.auto.attachments.tabular.image_result_replay_cap_chars`
- 范围:`600..30000`
- 是否需要重启:否(新 turn 读取时生效)
- Admin「附件」设置页新增视频相关配置,并写入 `oclaw.json`:
- `video_result_replay_cap_chars`(范围 `600..30000`)
- `video_transcript_chunk_size`(范围 `1..8000`)
- `video_transcript_chunk_overlap`(范围 `1..4000`)
- 路径:`plugins.entries.memory-wiki.auto.attachments.tabular`
- 是否需要重启:否(新 turn 读取时生效)
- Admin「附件」设置页新增压缩包统一预算配置,并写入 `oclaw.json`:
- `archive_max_depth`(默认 `2`)
- `archive_max_file_count`(默认 `200`)
- `archive_max_entry_bytes`(默认 `10485760`)
- `archive_max_total_uncompressed_bytes`(默认 `52428800`)
- 统一错误码:`archive_unsupported_format`, `archive_path_traversal`, `archive_max_depth_exceeded`, `archive_max_file_count_exceeded`, `archive_max_entry_bytes_exceeded`, `archive_max_total_uncompressed_bytes_exceeded`, `archive_link_entry_forbidden`, `archive_special_entry_forbidden`, `archive_parse_failed`
- 路径:`plugins.entries.memory-wiki.auto.attachments.tabular`
- 影响模块:`oclaw/platform/files/archive_processor.py`, `oclaw/platform/files/file_attachments.py`
- 是否需要重启:否(新 turn 读取时生效)
### Migration Checklist
- [x] 已更新 `oclaw/docs/ENVIRONMENT_VARIABLES.md`
- [x] 已更新 `README.md`
- [x] 已更新示例 env 文件
- [x] 已验证 Admin 配置页(如适用)
- [x] 已执行编译/测试回归
---
## 2026-04-21 / Unreleased
### Added