Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
前端 Agentic Tool Loop 已完整处理工具提取→执行→重注入循环, 后台分析器纯属重复调用 LLM。删除 background_analyzer.py 及其 两份提示词文件,清理所有调用点和文档引用。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
base64 仅增加 33% 传输开销且后端自己编码后又自己解码, JSON 中换行已转义不会破坏 SSE 分帧。现在 data 字段直接 是 JSON 字符串,前端 JSON.parse 即可。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
新增 apiserver/context_compressor.py: - litellm.token_counter() 计算消息 token 数 - 超过 100k 阈值时保留 system prompt + 最近 20 条消息 - 调用 gpt-4.1-nano 将早期消息生成摘要注入上下文 - NagaModel 登录态自动走网关,未登录走本地 API 配置 在 api_server.py 的 /chat/stream 中,build_conversation_messages() 之后、agentic loop 之前插入 compress_context() 调用。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 启动压缩:新会话启动时将上一会话历史压缩为摘要,注入 system prompt 的 <compact> 标签中,替代原有的 raw prev_messages 注入 - 运行时压缩:agentic loop 每轮开始前检查 token 是否超限(100k), 超限时压缩早期 loop 消息,摘要同样写入 <compact> 标签 - 已压缩检测:若上一会话已是压缩产物,直接提取 <compact> 内容复用 - 前端 SSE 进度:compress_start/progress/end 事件驱动压缩状态显示 - Bug 修复:MessageView 压缩提示使用非阻塞 setTimeout 替代 await Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
参考 Claude Code compaction 设计,将压缩提示词从开放式摘要改为 强制 6 分区结构化输出(用户意图/关键决策/已完成工作/问题与修复/ 待办事项/下一步行动),防止模型遗漏关键信息。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- compress_for_startup() 接受 previous_compact 参数,合并旧压缩记录与新对话 - message_manager 持久化 compact 字段到会话 JSON - 新增 _get_previous_session_id/get_session_compact/set_session_compact - max_tokens 2000→5000, timeout 30→60s,支持 3k-5k 字输出 - SUMMARIZE_PROMPT 增加两部分输入说明和继承规则 - 移除 is_already_compact(),改用 session metadata 存储压缩结果 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 压缩完成后在会话末尾追加 role="info" 的【已压缩上下文】标记 - info 消息持久化到磁盘,重启后仍可见,但 build_conversation_messages 自动过滤,永远不会发送给 LLM - 前端 MessageItem 将 info 渲染为居中分隔线样式 - 压缩检测方式改为检查上一个会话最后消息是否为 info 标记 - max_tokens 5000 → 5500 防止略微溢出 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Yidhar
pushed a commit
to Yidhar/Embla_System
that referenced
this pull request
Mar 3, 2026
上下文压缩系统 + 提示词优化
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
role="info"的【已压缩上下文】标记,持久化到磁盘但自动过滤不进入 LLM 上下文Test plan