Token Optimizer
Paste the following prompt into your AI chat to install this skill:
Follow https://skillhub.cn/install/skillhub.md and install @user_5accef42/tokenoptimizer.
About this skill
Solving Context Bloat in Multi-turn Conversations
In complex AI agent workflows, multi-turn conversations often lead to rapid context bloat. Verbose historical messages, redundant user inputs, and unconstrained model outputs not only increase token costs but also dilute the LLM's attention, reducing the success rate of core tasks.
Core Capabilities and Execution Mechanisms
The skill employs a structured compression and filtering mechanism to manage conversation context, featuring four key dimensions:
- Session State Management: Defaults to OFF. Once activated, it remains active for the entire session. Users can trigger a one-time skip (e.g., "skip this time") or a full deactivation via natural language.
- Intent Distillation: When conversations exceed a certain number of turns or context becomes cluttered, it extracts the current true task intent, filters out irrelevant historical discussions, and distills them into a single intent statement.
- Input Compression: Removes duplicate information and decorative filler (e.g., "maybe", "I think"), converting verbose natural language descriptions into high-density structured data like
JSONor tables. It performs quality checks to ensure edge cases are not lost. - Output Constraints: Applies specific token-saving directives based on output types. For example, code outputs skip boilerplate explanations and redundant comments; explanatory outputs are limited to 3 core points; data reports show only the Top 10 with a link to full data.
Boundaries and Safety Constraints
This mechanism is not suitable for all scenarios and must strictly adhere to safety limits:
- No Compression of Sensitive Data: Never remove security-sensitive information (e.g., API keys, credentials) or critical error-handling code to save tokens.
- Avoid Over-compression: Compression must not result in ambiguity. It must be performed while preserving rare scenarios (edge cases) and user preference constraints.
- Mandatory Integrity Validation: Before finalizing the optimization, validation scripts (e.g., validate_completeness.py) must be run to ensure the optimized input still contains all required information to complete the task.
- Exemption for Detail-heavy Tasks: When users require complete API documentation or detailed diagnostic logs, the one-time skip mechanism should be triggered to maintain full output.
Use Cases
- Compress long code-fixing history into the current bug task and remove irrelevant context.
- Convert verbose product lists or logs into structured JSON or table fields before analysis.
- Constrain code and data report outputs to bullets, top 10 items, and tables.
- Skip optimization once to generate a complete API documentation response.
Best For
- Engineers maintaining agent chat flows who need to control context length and response cost in multi-turn tasks.
- Developers writing code or API docs who need concise output while preserving error handling and edge cases.
- Ops or data staff handling logs, lists, and tables who need verbose inputs structured into actionable fields.
- Teams debugging AI agent workflows who need to manage activation, deactivation, and one-time overrides.
Related Skills
Collects daily conversations, task logs, and errors, then runs a nine-module review to surface blind spots, generate actions, and update memory.
Local long-term memory for AI agents that appends key facts and daily logs, supports cross-session context and search recall, and auto-archives old diaries to gzip files.
Run a grilling session to interact with or test AI agents.
A systematic prompt optimization skill that refines prompts using a four-step distillation framework (diagnose, structure, think, compress) and methodologies from four prompting masters.