Files
myWiki/concepts/agent-token-budget-optimization.md

51 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Agent Token Budget Optimization"
created: 2026-06-05
updated: 2026-06-05
type: concept
tags: [token-economics, budget, optimization, agent]
sources: [[chen-token-economics-llm-agents]]
---
# Agent Token Budget Optimization
**Agent Token 预算优化**是 [[micro-level-token-economics|微观 Token 经济学]] 的核心方法论,研究在给定 Token 预算约束下如何最大化 Agent 输出质量。对应新古典企业理论中的**要素替代优化**问题。
## 核心公式
```
max Quality(A; T_input, T_reason, T_memory, T_tool)
s.t. Σ(T_i × p_i) ≤ Budget
```
给定预算 B在推理、记忆、工具调用等 Token 类型之间进行最优分配。
## 五大优化策略
| 策略 | 描述 | 对应 Token 类型 |
|------|------|----------------|
| **KV-Cache 共享** | 多轮对话中共享注意力缓存 | 计算 Token |
| **投机解码** | 草稿模型加速推理 | 计算 Token |
| **上下文压缩** | 摘要/关键帧选择替代完整历史 | 记忆 Token |
| **工具调用批量化** | 合并多次工具调用为一次 | 工具 Token |
| **CoT 压缩** | 减少推理步骤的冗长度 | 推理 Token |
## 两阶段优化模式
实际系统通常采用两阶段:
1. **Adaptive Budget Allocation**:根据任务复杂度动态分配初始预算
2. **Online Budget Monitoring**:执行过程中监控消耗,触发重分配或提前终止
## 预算感知 vs 预算不感知
| 模式 | 行为 | 风险 |
|------|------|------|
| 预算不感知 | Agent 无限制生成,依赖外部截断 | 关键推理被截断、"Lost in the Middle" |
| 预算感知 | Agent 在已知预算内主动优化 | 策略性压缩、质量-效率权衡 |
## 与相关概念
- [[token-efficiency|Token 效率]] 是预算优化的具体技术目标
- [[differentiable-token-budgeting|可微 Token 预算]] 是前沿方向——将预算从外生参数变为可学习参数
- [[cost-quality-speed-trilemma|三元悖论]] 中成本维度直接对应预算约束