slimtoken.optimize_messages
Minify prompts and compress tool results to reduce token usage while keeping message structure and tool-call validity intact. Returns minified messages and token counts.
Instructions
Reduce prompt size while preserving message structure and tool-call validity (pair-safe, fence-aware). Returns the minified messages plus token counts. Lossy by default (distill + tool-result compression); disable stages via the SLIMTOKEN_MINIFY_* env knobs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tools | No | tool definitions to minify | |
| format | No | request format (anthropic=identity; openai/ollama are normalized to canonical, minified, then returned) | anthropic |
| system | No | system prompt (string or list of text blocks) | |
| messages | Yes | Anthropic-style messages array | |
| max_input_tokens | No | override the token_budget (hard prune cap) |