save-token
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese💰 Save Token | Token 节省器
💰 Token 节省器
A guiding skill that teaches agents how to save tokens by avoiding duplicate context.指导 Agent 如何通过避免重复上下文来节省 Token 的技能。
这是一项指导性技能,教Agent如何通过避免重复上下文来节省Token。
⚠️ Important Clarification | 重要说明
⚠️ 重要说明
| Clarification | 说明 |
|---|---|
| This is a guiding skill | Skill itself cannot modify agent's runtime context |
| Agent performs the action | Agent follows the guidance to optimize context |
| 这是一个指导性 Skill | Skill 本身不能修改 Agent 的运行时上下文 |
| 由 Agent 执行操作 | Agent 遵循指导来优化上下文 |
| 说明 | 详情 |
|---|---|
| 这是一项指导性Skill | Skill本身不能修改Agent的运行时上下文 |
| 由Agent执行操作 | Agent遵循指导来优化上下文 |
🎯 When to Use | 使用时机
🎯 使用时机
Agent 自动触发条件(满足任一即应调用):
- 用户提到 "token" / "成本" / "省钱" / "费用"
- 对话已超过 10 轮
- 同一文件被读取超过 1 次
- 任务前上下文超过 5000 字符
| Situation | Action | 场景 | 操作 |
|---|---|---|---|
| User mentions "token" or "cost" | Apply save-token strategies | 用户提到 token 或成本 | 应用 save-token 策略 |
| Long conversation (>10 turns) | Summarize old context | 长对话(>10轮) | 摘要旧上下文 |
| File read multiple times | Reference previous read, don't re-read | 文件被多次读取 | 引用之前的读取,不重复读取 |
| Repeated error messages | Summarize error pattern, don't repeat full error | 重复错误消息 | 摘要错误模式,不重复完整错误 |
Agent自动触发条件(满足任一即应调用):
- 用户提到 "token" / "成本" / "省钱" / "费用"
- 对话已超过10轮
- 同一文件被读取超过1次
- 任务前上下文超过5000字符
| 场景 | 操作 |
|---|---|
| 用户提到token或成本 | 应用save-token策略 |
| 长对话(>10轮) | 摘要旧上下文 |
| 文件被多次读取 | 引用之前的读取结果,不重复读取 |
| 重复错误消息 | 摘要错误模式,不重复发送完整错误信息 |
📋 Token-Saving Strategies | 节省 Token 策略
📋 Token节省策略
Strategy 1: Summarize Instead of Re-sending | 策略1:摘要代替重发
策略1:摘要代替重发
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
做法:
- 摘要早期对话的关键点
- 用简洁摘要替换完整历史
- 只保留最相关的最近消息
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."适用场景:旧对话上下文不再直接相关时
操作方式:
- 摘要早期对话的关键点
- 用简洁摘要替换完整历史
- 仅保留最相关的近期消息
示例:
❌ 不当做法:重发50轮对话(10000+ Token)
✅ 正确做法:"之前的上下文:用户正在分析股票投资策略。
已做出的关键决策:优先选择低市盈率标的,检查现金流。
当前重点:特定公司分析。"Strategy 2: Reference Instead of Repeat | 策略2:引用代替重复
策略2:引用代替重复
When: 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
做法:
- 不要重新读取整个文件
- 引用已提取的关键信息
- 仅在需要时读取新部分
Example:
❌ Bad: Reading the same 200KB file again
✅ Good: "As we found earlier in the file, the revenue is $50M..."适用场景:需要再次引用同一文件/内容时
操作方式:
- 不要重新读取整个文件
- 引用已提取的关键信息
- 仅在需要时读取新部分
示例:
❌ 不当做法:再次读取同一200KB文件
✅ 正确做法:"正如我们之前从该文件中发现的,营收为5000万美元..."Strategy 3: De-duplicate Identical Blocks | 策略3:去重相同块
策略3:去重相同内容块
When: Identical text appears multiple times in context
当:相同文本在上下文中多次出现时
Do:
- Identify identical blocks (≥100 characters)
- Keep only the first occurrence
- Note what was removed
做法:
- 识别相同块(≥100字符)
- 只保留首次出现
- 记录删除了什么
Example:
❌ Bad: Same error message appears 5 times (500 chars × 5 = 2500 chars)
✅ Good: "[Error message appeared 5 times, showing once]: Connection timeout..."适用场景:相同文本在上下文中多次出现时
操作方式:
- 识别相同内容块(≥100字符)
- 仅保留首次出现的内容
- 记录已移除的内容
示例:
❌ 不当做法:相同错误消息出现5次(500字符×5=2500字符)
✅ 正确做法:"[错误消息出现5次,仅展示1次]:连接超时..."Strategy 4: Compress Verbose Output | 策略4:压缩冗长输出
策略4:压缩冗长输出
When: Tool output or file content is very long
当:工具输出或文件内容很长时
Do:
- Extract only relevant parts
- Summarize the rest
- Note 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."适用场景:工具输出或文件内容非常长时
操作方式:
- 仅提取相关部分
- 摘要其余内容
- 记录来源以供参考
示例:
❌ 不当做法:包含完整的1000行日志文件
✅ 正确做法:"日志文件(1000行):关键错误位于第45、78、234行。
规律:每5分钟连接中断一次。如需完整日志可提供。"🔄 Workflow | 工作流程
🔄 工作流程
重要:Agent 应在每次任务开始前主动检查以下条件:
每次任务开始前的检查流程:
1. 检查对话轮数:是否 > 10 轮?
2. 检查上下文大小:是否 > 5000 字符?
3. 检查文件读取:是否有文件被读取超过 1 次?
4. 检查用户意图:用户是否提到 "token" / "成本" / "省钱"?
如果满足任一条件 → 应用 save-token 策略 → 报告优化结果 → 继续执行任务建议:Agent 可以在回复用户前,先问自己:
- "我的上下文是否已经很长?"
- "是否有重复内容我可以省略?"
- "我可以用摘要代替重发吗?"
重要:Agent应在每次任务开始前主动检查以下条件:
每次任务开始前的检查流程:
1. 检查对话轮数:是否 > 10 轮?
2. 检查上下文大小:是否 > 5000 字符?
3. 检查文件读取:是否有文件被读取超过 1 次?
4. 检查用户意图:用户是否提到 "token" / "成本" / "省钱"?
如果满足任一条件 → 应用save-token策略 → 报告优化结果 → 继续执行任务建议:Agent可以在回复用户前,先问自己:
- "我的上下文是否已经很长?"
- "是否有重复内容我可以省略?"
- "我可以用摘要代替重发吗?"
📊 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%)应用Token节省策略时,需告知用户:
💡 已应用Token优化:
- 策略:[策略名称]
- 优化前上下文:X Token
- 优化后上下文:Y Token
- 节省量:Z Token(P%)⚠️ What This Skill Cannot Do | 此 Skill 不能做的事
⚠️ 本Skill无法实现的功能
| Cannot Do | Reason | 不能做 | 原因 |
|---|---|---|---|
| Directly modify context | Skill is guidance, not execution | 直接修改上下文 | Skill 是指导,不是执行 |
| Automatically delete content | Agent must decide what to keep | 自动删除内容 | Agent 必须决定保留什么 |
| Guarantee exact savings | Depends on implementation | 保证精确节省量 | 取决于实现方式 |
| 无法实现的功能 | 原因 |
|---|---|
| 直接修改上下文 | Skill仅为指导性质,不具备执行能力 |
| 自动删除内容 | 需由Agent决定保留哪些内容 |
| 保证精确节省量 | 取决于具体实现方式 |
✅ What This Skill Does | 此 Skill 能做的事
✅ 本Skill可实现的功能
| Does | Description | 能做 | 描述 |
|---|---|---|---|
| Provide strategies | Teaches how to save tokens | 提供策略 | 教如何节省 Token |
| Identify opportunities | Helps recognize when to apply | 识别机会 | 帮助识别何时应用 |
| Guide implementation | Shows best practices | 指导实现 | 展示最佳实践 |
| 可实现的功能 | 描述 |
|---|---|
| 提供策略 | 教授如何节省Token的方法 |
| 识别应用时机 | 帮助判断何时应用策略 |
| 指导实现 | 展示最佳实践 |
📝 Version | 版本
📝 版本
- Version: 1.1.0
- Updated: 2026-03-12
- Change: Clarified that this is a guiding skill, not an execution script
- 版本:1.1.0
- 更新日期:2026-03-12
- 更新内容:明确本Skill为指导性技能,而非执行脚本