feat: 上下文压缩支持状态持久化缓存,前端过滤隐藏消息

- summarization_middleware 摘要缓存写入 LangGraph thread state,跨进程/重启可复用
- 摘要消息改为 SystemMessage,提示模型静默使用、不泄露
- thread_state 新增 context_summary_cache 字段
- app_config 加载时记录 summarization 配置日志
- config.yaml 压缩触发/保留阈值调整为生产值(token 预算)
- 前端 input-box / message-list 过滤 hide_from_ui 消息

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
AdministratorandClaude Opus 4.8 committed 2026-06-16 22:16:06 +08:00
1 parent 5f39879e4d
commit 5b610fd807
7 files changed
+159 -71

No files matched your search

+7 -10
View File
@@ -310,20 +310,17 @@ summarization:
# model_name: deepseek-chat
trigger:
- type: tokens
value: 8000
value: 120000
- type: messages
value: 12
value: 160
# Keep a small *token* budget of recent context (same unit as the token
# trigger, well below it). This is what the model receives after compaction:
# [summary, ~16000 tokens of recent turns]. Small keep = small model context
# [summary, ~40000 tokens of recent turns]. Small keep = small model context
# (fast, no overflow) AND infrequent re-compaction — the preserved window
# grows from ~16000 up to the 60000 trigger before folding into a new summary,
# grows from ~40000 up to the 120000 trigger before folding into a new summary,
# which spans many turns. The full conversation still stays in state for the
# page; only what is sent to the model is compressed.
keep:
type: messages # 测试值:压缩后只保留最近 6 条原始消息
value: 6
# 生产值改用 token 预算:
# type: tokens
# value: 16000
trim_tokens_to_summarize: 4000
type: tokens
value: 40000
trim_tokens_to_summarize: 8000