Skip to content

Adopt acp-kernel stripHistoricalImages for historical image payloads (opt-in) #321

Description

@ranxianglei

来源: ranxianglei/billion-context#617 分析「压缩期剥离历史图像载荷」时派生。剥离机制已下沉 acp-kernel wire 层(见下方关联 PR),本 issue 跟踪在 billion-context-pi 侧的接入。

背景

billion-context#617 请求:在压缩过程中剥离历史消息的图像载荷,仅保留最近 N 条的图像。经与 owner 讨论,剥离机制已下沉到 acp-kernel 的 wire 层,作为跨宿主共享原语:

  • 内核机制: acp-kernel#215 —— stripHistoricalImages(body, protocol, keepRecent)
    • 覆盖 anthropic / openai / responses 三协议
    • 类型判定(远程 URL 图像同样剥离,非仅 data URL)
    • 图像独占消息折叠为 "[image]" 文本占位符(Responses 用 input_text),消息数 / 角色序保持稳定
    • 无变化时返回原引用(no-op identity),便于跳过重序列化

billion-context-pi 作为 acp-kernel 的进程内宿主,在重建上游请求体时同样会携带这些历史图像字节,建议接入该原语获得同等收益。

建议做法(对齐 billion-context)

  1. 新增 host-side 策略开关(策略留在宿主、不进内核):如 compress.stripImages(默认关)+ compress.stripImagesKeepRecent(默认 5),沿用项目既有的配置合并层级。
  2. 在 wire 重建入口调用 stripHistoricalImages(parsedBody, protocol, keepRecent),用返回体替代原始 parsed body 送入 codec(具体入口点需在 pi 代码中定位后确认)。
  3. 默认关闭以保持现有行为;开启后历史图像被剥离、最近 N 条保留。

依赖 / 顺序

需等 acp-kernel#215 合并并发布新版本后,本项目 bump acp-kernel 精确版本 pin,再接入调用。

关联

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

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions