84 lines
3.4 KiB
Markdown
84 lines
3.4 KiB
Markdown
<!-- Generated by scripts/gen-website-api.ts — do not edit by hand. Run `pnpm run gen-website-api` to regenerate. -->
|
|
|
|
# ctx.toolResultPrune
|
|
|
|
`ToolResultPruneService` — provided by `@deepseek-ai/dsh-compact-tool-result-prune`.
|
|
|
|
Deterministic head/middle/tail pruning for current tool-result surface nodes.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/compact/compact-tool-result-prune/src/index.ts#L39)
|
|
|
|
### ctx.toolResultPrune.config
|
|
|
|
```ts website-api
|
|
/** Resolved and immutable character budgets. */
|
|
readonly config: ResolvedConfig
|
|
```
|
|
|
|
Resolved and immutable character budgets.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/compact/compact-tool-result-prune/src/index.ts#L47)
|
|
|
|
### ctx.toolResultPrune.measureContent(blocks)
|
|
|
|
```ts website-api
|
|
/**
|
|
* 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](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/compact/compact-tool-result-prune/src/index.ts#L59)
|
|
|
|
### ctx.toolResultPrune.pruneContent(blocks)
|
|
|
|
```ts website-api
|
|
/**
|
|
* 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](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/compact/compact-tool-result-prune/src/index.ts#L74)
|
|
|
|
### ctx.toolResultPrune.pruneSession(session)
|
|
|
|
```ts website-api
|
|
/**
|
|
* 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](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/compact/compact-tool-result-prune/src/index.ts#L124)
|