# 473 2026 02 02 Pruning Token Estimation Optimization 767dd52d

> Summary

- Skill: `tools-only/473-2026-02-02-pruning-token-estimation-optimization-767dd52` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/473-2026-02-02-pruning-token-estimation-optimization-767dd52`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/473-2026-02-02-pruning-token-estimation-optimization-767dd52/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/tools-only/473-2026-02-02-pruning-token-estimation-optimization-767dd52

---


# Summary

Reduced redundant token estimation in tool-output pruning while preserving pruning behavior.

# Context

The pruning loop in `prune_old_tool_outputs()` was estimating token counts twice for pruned parts and recalculating placeholder tokens for every mutation.

# Changes

- Added `PRUNE_PLACEHOLDER_TOKENS` to cache placeholder token counts.
- Introduced `get_part_content_text()` to normalize part content before estimation/pruning.
- Passed precomputed token counts into `prune_part_content()` to avoid re-estimation.
- Stopped token estimation after `protect + minimum` is satisfied while still scanning for parts to prune.

# Behavioral Impact

Pruning decisions and output remain unchanged; token estimation work is reduced and placeholder token counting is cached.

# Related Cards

- [[token-pruning-efficiency-plan]]

