Files
deepseek-harness/website/zh-CN/api/harness/tool-result-prune.md
2026-07-20 17:02:28 +08:00

3.4 KiB

ctx.toolResultPrune

ToolResultPruneService — provided by @deepseek-ai/dsh-compact-tool-result-prune.

Deterministic head/middle/tail pruning for current tool-result surface nodes.

Source

ctx.toolResultPrune.config

/** Resolved and immutable character budgets. */
readonly config: ResolvedConfig

Resolved and immutable character budgets.

Source

ctx.toolResultPrune.measureContent(blocks)

/**
 * Measure text content in Unicode code points; non-text blocks cost zero.
 * @param blocks - tool-result content to measure.
 * @returns total Unicode code points across text blocks.
 */
measureContent(blocks: readonly ContentBlock[]): number

Measure text content in Unicode code points; non-text blocks cost zero.

  • blocks — tool-result content to measure.

Returns total Unicode code points across text blocks.

Source

ctx.toolResultPrune.pruneContent(blocks)

/**
 * Replace an over-budget text middle while retaining rich-block order.
 * Text slicing is by Unicode code point, not UTF-16 code unit, so a retained
 * boundary cannot split a surrogate pair. Grapheme clusters may still split.
 * @param blocks - original tool-result content.
 * @returns pruned content, or `null` when the text is within budget.
 */
pruneContent(blocks: readonly ContentBlock[]): ContentBlock[] | null

Replace an over-budget text middle while retaining rich-block order. Text slicing is by Unicode code point, not UTF-16 code unit, so a retained boundary cannot split a surrogate pair. Grapheme clusters may still split.

  • blocks — original tool-result content.

Returns pruned content, or null when the text is within budget.

Source

ctx.toolResultPrune.pruneSession(session)

/**
 * Prune every over-budget tool result from one stable current-surface snapshot.
 * Each replacement preserves the complete event data except for `content`,
 * and points at the shadowed node for durable provenance and replay.
 * @param session - session whose current surface is rewritten.
 * @returns landed replacements and aggregate Unicode-code-point savings.
 * @throws when the session rejects a replacement; replacements committed
 * earlier in the pass remain durable.
 */
pruneSession(session: Session): PruneResult

Prune every over-budget tool result from one stable current-surface snapshot. Each replacement preserves the complete event data except for content, and points at the shadowed node for durable provenance and replay.

  • session — session whose current surface is rewritten.

Returns landed replacements and aggregate Unicode-code-point savings.

Source