multica/src/agent/context-window
Jiang Bohan 3dd7ff52d6 feat(context): add tool result pruning for smarter context management
Two-phase pruning approach based on OpenClaw's microcompact-style:
- Soft Trim (30% utilization): Keep head 1500 + tail 1500 chars of large tool results
- Hard Clear (50% utilization): Replace old tool results with placeholder

Protections:
- Never prunes before first real user message (bootstrap protection)
- Protects last 3 assistant messages and their corresponding tool results
- Skips image-containing tool results
- Respects tool allow/deny lists

Enabled by default in tokens/summary compaction modes.
2026-02-05 15:50:58 +08:00
..
guard.test.ts test(context): add unit tests for context window guard 2026-01-30 14:00:38 +08:00
guard.ts docs: translate comments from Chinese to English (#15) 2026-01-30 04:01:14 +08:00
index.ts feat(context): add tool result pruning for smarter context management 2026-02-05 15:50:58 +08:00
summarization.ts docs: translate comments from Chinese to English (#15) 2026-01-30 04:01:14 +08:00
token-estimation.test.ts test(context): add unit tests for token estimation and compaction 2026-01-30 13:54:57 +08:00
token-estimation.ts docs: translate comments from Chinese to English (#15) 2026-01-30 04:01:14 +08:00
tool-result-pruning.test.ts feat(context): add tool result pruning for smarter context management 2026-02-05 15:50:58 +08:00
tool-result-pruning.ts feat(context): add tool result pruning for smarter context management 2026-02-05 15:50:58 +08:00
types.ts docs: translate comments from Chinese to English (#15) 2026-01-30 04:01:14 +08:00