trim_llm_context
Prune LLM message history to fit token budgets by deduplicating repetitive outputs, condensing payloads, and preserving recent turns and system instructions.
Instructions
[Free Promotional Preview / Zero Auth] Compresses and prunes LLM message history to strictly fit within a target token budget.
Deduplicates repetitive tool outputs, condenses bulky historical payloads,
and prunes older turns while preserving system instructions and recent context.
Args:
messages: Native list of OpenAI/Anthropic format message dicts (or JSON string).
messages_json: Optional stringified messages for backward compatibility.
max_tokens: Maximum target token count (default: 4000).
preserve_recent_turns: Number of recent conversational turns to preserve untouched (default: 4).
payment_signature: Optional x402 Base USDC transaction hash or developer mock key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messages | No | ||
| max_tokens | No | ||
| messages_json | No | ||
| payment_signature | No | ||
| preserve_recent_turns | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |