Skip to content

feat: absorb tool for instant tool-result compression (issue #14) - #213

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-23_absorb-tool
Open

feat: absorb tool for instant tool-result compression (issue #14)#213
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-23_absorb-tool

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Adapts the proxy to acp-kernel 0.0.45's new absorb pipeline (kernel PR #139, merged) — closes #14 on the companion billion-context-pi tracker direction: 小上下文场景下, 工具调用后模型立即复述关键结果, 原始工具输出下一轮隐藏.

  • src/absorb.ts (new): absorbEnabled / applyAbsorbConfig (settings → kernel Config.absorb, percent parsing for contextThresholdPct) and executeAbsorb. The wire result carries the model's summary verbatim inside <absorbed-summary> — the absorb tool_use is rewritten to text on the wire, so that text is the only durable record of the original output.
  • Injection: absorb tool + system-prompt section for anthropic / openai / responses (streaming loops included), gated on absorb being enabled in compress settings. Plugin manifest and MCP tool list now advertise absorb (5 tools); plugin tool API executes it under the session lock.

Kernel 0.0.31 → 0.0.45 upgrade fallout (fixed here)

  1. openaiToCore now hoists the leading system/developer prefix out of the fold space. prepareOpenai re-injects systemText (restoring a developer head role) — without this the host system prompt is silently dropped from every rebuilt request.
  2. Kernel KEEP_LAST_ORPHANED=2 (issue release v0.1.2 #9 fix) keeps the newest two orphaned compress calls visible. In plugin mode the wire echo of an executed compress carries a host id that never matches the block's plugin_* call id → permanent orphan → stays visible. hidePluginEchoCompressCalls drops the consumed tail pair before the turn.
  3. Pinned acp-kernel to exact 0.0.45-pr.160.14 (the npm preview of kernel release PR refactor: adopt acp-kernel/wire — codecs move to the kernel #160). Follow-up commit flips this to 0.0.45 once the kernel release lands on npm — merge this PR after that.

Tests

518/518 pass (node --import tsx --test), tsc --noEmit --project tsconfig.build.json clean, tsup build clean:

  • roundtrip tests adapted to the hoist contract (systemText + injectOpenaiSystem)
  • manifest / MCP tool lists now expect 5 tools
  • plugin fold test passes again (echo pair hidden, range folded, summary retrievable via search_context)
  • 6 new unit tests for absorbEnabled / applyAbsorbConfig / executeAbsorb (disabled fast-fail, missing-summary guidance, success records + hides + verbatim summary, idempotency, unknown ref)

Merge is human-only per AGENTS.md.

Adapts the proxy to acp-kernel 0.0.45's absorb pipeline:

- src/absorb.ts: absorb settings resolution (absorbEnabled,
  applyAbsorbConfig with percent parsing) and executeAbsorb — the wire
  result text carries the model's summary verbatim inside
  <absorbed-summary> (the absorb tool_use is rewritten to text, so this
  is the only durable record).
- Tool injection for all three protocols (anthropic/openai/responses,
  streaming loops included), plugin manifest + MCP tool list now
  advertise absorb; plugin tool API can execute it.
- Kernel 0.0.31 -> 0.0.45-pr.160.14 (exact pin; flips to 0.0.45 when
  kernel release PR #160 merges):
  - openaiToCore now hoists the leading system/developer prefix out of
    the fold space: prepareOpenai re-injects systemText (and restores a
    developer head role) or the host system prompt is silently lost.
  - KEEP_LAST_ORPHANED=2 changed hide-consumed semantics: plugin-mode
    wire echoes of executed compress calls are orphans that stay
    visible; hidePluginEchoCompressCalls drops the consumed tail pair.
- Tests: roundtrip hoist contract, manifest/MCP 5-tool lists, 6 new
  absorb unit tests. 518/518 pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant