473 2026 02 02 Pruning Token Estimation Optimization 767dd52d
ASecurityReduced redundant token estimation in tool-output pruning while preserving pruning behavior. The pruning loop in `prune_old_tool_outputs()` was estimating token counts twice for pruned parts and recalculating placeholder tokens for every mutation. - 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. -...
- 9 stars
- 0 votes
- 0 copies
- 1 view
- Added June 1, 2026
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add tools-only/X-Skills --skill 473-2026-02-02-pruning-token-estimation-optimization_767dd52d --agent claude-codeAre you the author of 473 2026 02 02 Pruning Token Estimation Optimization 767dd52d?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tools-only-473-2026-02-02-pruning-token-estimation-optimizati)---
title: Pruning Token Estimation Optimization
link: pruning-token-estimation-optimization
type: delta
path: src/tunacode/core/agents/resume/prune.py
depth: 2
seams: [M]
ontological_relations:
- relates_to: [[prune_old_tool_outputs]]
- relates_to: [[token_estimation]]
- affects: [[context-window]]
tags:
- performance
- pruning
- tokens
created_at: 2026-02-02T21:05:00-06:00
updated_at: 2026-02-02T21:05:00-06:00
uuid: 0172237b-d7e0-40ca-b130-e8dcc5bd72d2
---
# 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]]
Files in this skill
- README.md
- skill.md
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.