A guiding skill that teaches agents how to save tokens by avoiding duplicate context.
A skill that guides Agents on how to save Tokens by avoiding duplicate context.
⚠️ Important Clarification | Important Note
| Clarification | Description |
|---|---|
| This is a guiding skill | Skill itself cannot modify agent's runtime context |
| Agent performs the action | Agent follows the guidance to optimize context |
| This is a guiding Skill | The Skill itself cannot modify the Agent's runtime context |
| The Agent performs the operations | The Agent follows the guidance to optimize context |
🎯 When to Use | When to Use
Conditions for the Agent to trigger automatically(call if any one is met):
- The user mentions "token" / "cost" / "save money" / "expense"
- The conversation has exceeded 10 turns
- The same file has been read more than 1 time
- The pre-task context exceeds 5000 characters
| Situation | Action | Scenario | Action |
|---|---|---|---|
| User mentions "token" or "cost" | Apply save-token strategies | The user mentions token or cost | Apply the save-token strategy |
| Long conversation (>10 turns) | Summarize old context | Long conversation (>10 turns) | Summarize old context |
| File read multiple times | Reference previous read, don't re-read | The file is read multiple times | Reference the previous read, do not read again |
| Repeated error messages | Summarize error pattern, don't repeat full error | Repeated error messages | Summarize the error pattern, do not repeat the full error |
📋 Token-Saving Strategies | Token-Saving Strategies
Strategy 1: Summarize Instead of Re-sending | Strategy 1: Summarize Instead of Re-sending
When: Old conversation context is no longer directly relevant When: old conversation context is no longer directly relevant
Do:
- Summarize key points from earlier conversation
- Replace full history with concise summary
- Keep only the most relevant recent messages
How to do it:
- Summarize the key points of the early conversation
- Replace the full history with a concise summary
- Keep only the most relevant recent messages
Example:
❌ Bad: Re-sending 50 turns of conversation (10,000+ tokens)
✅ Good: "Previous context: User was analyzing stock investment strategies.
Key decisions made: prioritize low P/E, check cash flow.
Now focusing on: specific company analysis."
Strategy 2: Reference Instead of Repeat | Strategy 2: Reference Instead of Repeat
When: Same file/content needs to be referenced again When: the same file/content needs to be referenced again
Do:
- Don't re-read the entire file
- Reference the key information already extracted
- Only read new sections if needed
How to do it:
- Do not re-read the entire file
- Reference the key information already extracted
- Only read new parts when needed
Example:
❌ Bad: Reading the same 200KB file again
✅ Good: "As we found earlier in the file, the revenue is $50M..."
Strategy 3: De-duplicate Identical Blocks | Strategy 3: De-duplicate Identical Blocks
When: Identical text appears multiple times in context When: identical text appears multiple times in the context
Do:
- Identify identical blocks (≥100 characters)
- Keep only the first occurrence
- Note what was removed
How to do it:
- Identify identical blocks (≥100 characters)
- Keep only the first occurrence
- Record what was deleted
Example:
❌ Bad: Same error message appears 5 times (500 chars × 5 = 2500 chars)
✅ Good: "[Error message appeared 5 times, showing once]: Connection timeout..."
Strategy 4: Compress Verbose Output | Strategy 4: Compress Verbose Output
When: Tool output or file content is very long When: tool output or file content is very long
Do:
- Extract only relevant parts
- Summarize the rest
- Note the source for reference
How to do it:
- Extract only the relevant parts
- Summarize the rest
- Record the source for reference
Example:
❌ Bad: Including full 1000-line log file
✅ Good: "Log file (1000 lines): Key errors on lines 45, 78, 234.
Pattern: Connection drops every 5 minutes. Full log available if needed."
🔄 Workflow | Workflow
Important: The Agent should proactively check the following conditions before starting each task:
每次任务开始前的检查流程:
1. 检查对话轮数:是否 > 10 轮?
2. 检查上下文大小:是否 > 5000 字符?
3. 检查文件读取:是否有文件被读取超过 1 次?
4. 检查用户意图:用户是否提到 "token" / "成本" / "省钱"?
如果满足任一条件 → 应用 save-token 策略 → 报告优化结果 → 继续执行任务
Suggestion: Before replying to the user, the Agent can first ask itself:
- "Is my context already very long?"
- "Is there duplicate content I can omit?"
- "Can I use a summary instead of resending?"
📊 Reporting Format | Reporting Format
When applying token-saving strategies, inform the user:
💡 Token Optimization Applied:
- Strategy: [Strategy Name]
- Context before: X tokens
- Context after: Y tokens
- Saved: Z tokens (P%)
⚠️ What This Skill Cannot Do | What This Skill Cannot Do
| Cannot Do | Reason | Cannot do | Reason |
|---|---|---|---|
| Directly modify context | Skill is guidance, not execution | Modify context directly | The Skill is guidance, not execution |
| Automatically delete content | Agent must decide what to keep | Automatically delete content | The Agent must decide what to keep |
| Guarantee exact savings | Depends on implementation | Guarantee exact savings | Depends on the implementation |
✅ What This Skill Does | What This Skill Can Do
| Does | Description | Can do | Description |
|---|---|---|---|
| Provide strategies | Teaches how to save tokens | Provide strategies | Teach how to save Tokens |
| Identify opportunities | Helps recognize when to apply | Identify opportunities | Help identify when to apply |
| Guide implementation | Shows best practices | Guide implementation | Show best practices |
📝 Version | Version
- Version: 1.1.0
- Updated: 2026-03-12
- Change: Clarified that this is a guiding skill, not an execution script