Skip to content

feat(absorb): instant tool-result compression for small contexts (#14) - #208

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

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

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Implements #14 (adapter side; kernel side is ranxianglei/acp-kernel#139).

What

Small-context setups (e.g. a 10K window) can't wait for the regular nudge-based compression — the model runs out of room. This adds the absorb tool: when enabled, large tool results (default ≥1000 estimated tokens) get a forced [ACP absorb] suffix demanding the model immediately call absorb({ ref, summary }). After absorption the original tool-call+result pair is hidden from later turns; the summary-carrying absorb call is the durable record. Absorb calls stay ordinary tool calls — the regular compression system can fold them into blocks later (orthogonal).

Config (acp.json)

{ "absorb": true }

or tuned: absorb.minToolTokens (1000), absorb.contextThresholdPct (0 = size alone decides), absorb.excludeTools ([]), absorb.toolName ("absorb"). Documented in CONFIGURATION.md + CONFIGURATION.zh-CN.md.

Changes

  • src/absorb-tool.ts — tool handler (kernel applyAbsorb + parseAbsorbInput), follows compress-tool patterns (throw on error so pi marks isError)
  • src/config.tsAbsorbSettings, resolveAbsorb (boolean shorthand + % parsing), resolveConfig mapping
  • src/index.ts — registration when enabled, re-registration on session_start (acp.json reload), absorb system-prompt section
  • src/user-config.tsabsorb key (boolean or object)
  • tests/absorb-tool.test.ts — 6 tests: config mapping, gated registration, forced prompt on large results only, hide-pair+keep-summary end-to-end, error paths, system prompt section
  • CONFIGURATION.md / CONFIGURATION.zh-CN.md / CHANGELOG.md

Notes

  • Merge AFTER acp-kernel#139 ships to npm, then the release commit bumps the acp-kernel pin (currently 0.0.41) per AGENTS.md §5. Until then CI may fail on the not-yet-released kernel APIs.
  • Validated locally against the kernel branch build overlaid onto node_modules (AGENTS.md §5 pre-validation): 415/415 tests, typecheck clean, build clean.

Registers the absorb tool when acp.json enables it (absorb: true or an
absorb object). Large tool results get a forced [ACP absorb] prompt via
the kernel pipeline; the model calls absorb({ ref, summary }) and the
original tool-call+result pair is hidden from later turns, the summary
becomes the durable record. Absorb calls stay ordinarily compressible.

- src/absorb-tool.ts: tool handler (kernel applyAbsorb, parseAbsorbInput)
- src/config.ts: AbsorbSettings + resolveAbsorb + resolveConfig mapping
- src/index.ts: registration, session-start re-registration, system prompt
- src/user-config.ts: acp.json key (boolean or object)
- tests/absorb-tool.test.ts: 6 tests (config, registration, prompt gating,
  hide+keep-summary, error paths, system prompt section)
- CONFIGURATION.md / CONFIGURATION.zh-CN.md / CHANGELOG.md

Requires acp-kernel with the absorb API (branch 2026-08-23_absorb-tool,
to be released before the adapter release bumps its pin).
@ranxianglei ranxianglei mentioned this pull request Aug 24, 2026
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