Skip to content

[Phase 7] 上下文压缩可靠性提升 #18

Description

@zhuqingyv

目标模式执行版

目标:提升上下文压缩失败时的可靠性,保证长对话不会因为 compact 失败而破坏工具协议或丢失当前任务。

当前代码口径

以当前实现为准,重点关注:

  • compactActiveContext
  • summarizeContextItems
  • ContextManager.applyPatch
  • tool_call/tool_result 配对保护

范围

  • 区分摘要失败类型:
    • summarizer 调用异常。
    • 返回非 JSON。
    • 返回空数组。
    • 摘要过短/信息量不足。
  • 失败时走确定性 fallback:保留 system、当前/最近 user、当前 task、未闭合 tool group、最近 tail。
  • compact 后必须仍满足 provider message 协议。

非目标

执行切片

  1. 为 compact 失败分类补单元测试。
  2. 实现短摘要/异常的确定性 fallback。
  3. 补 tool_call/tool_result 配对不被破坏的边界测试。
  4. 增加一个固定 >50 轮或强制小 contextWindow 的稳定性用例。

验收标准

  • summarizer 异常、非 JSON、空摘要、短摘要都有测试。
  • compact 后请求中仍有 user message。
  • tool_call/tool_result 不拆组,无 orphan tool。
  • fallback 有明确原因和可观测事件/日志。
  • 固定长对话测试不因上下文爆炸或 provider schema 错失败。
  • npm testnpm run build 通过。

依赖关系

本 issue 可先执行,但不能扩散到 #19#19 负责长期 Active Context / pool 治理。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions