Skip to content
Back to skills

473 2026 02 02 Pruning Token Estimation Optimization 767dd52d

ASecurity

Reduced 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
ai-agentsperformance

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned June 1, 2026

npx -y skills add tools-only/X-Skills --skill 473-2026-02-02-pruning-token-estimation-optimization_767dd52d --agent claude-code

Installs into .claude/skills of the current project.

Are 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.

Security grade badge for 473 2026 02 02 Pruning Token Estimation Optimization 767dd52d
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-473-2026-02-02-pruning-token-estimation-optimizati/badge)](https://www.skillsdirectory.com/skills/tools-only-473-2026-02-02-pruning-token-estimation-optimizati)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.md1 KB
  • skill.md1.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.