通过清理无效对话记录,显著降低大模型代理的计算成本。
Reducing Cost of LLM Agents with Trajectory Reduction
- 运行时自动识别并删除冗余对话内容
- 输入 token 减少 39.9%-59.7%,计算成本降 21.1%-35.9%
- 适合追求高效部署的大模型代理开发者
基于大语言模型(LLMs)的多轮代理系统在软件工程任务中日益流行。尽管其表现优异,但因对话轨迹不断增长导致输入 token 计算成本高昂,效率问题长期被忽视。本文提出一种推理阶段的轨迹压缩方法——AgentDiet,通过分析现有代理轨迹,发现大量无用、冗余和过期信息普遍存在,可被安全移除而不影响性能。我们在一个顶尖编码代理上实现 AgentDiet,评估结果表明,在两种 LLM 和两个基准测试上,可减少 39.9%-59.7% 的输入 token,总计算成本降低 21.1%-35.9%,且保持原有性能不变。这证明推理阶段轨迹压缩是提升代理系统效率的可行方向。
原文摘要 · Abstract (English)
Multi-turn agent systems based on Large Language Models (LLMs) have become increasingly popular for software engineering tasks. While LLM agents demonstrate promising effectiveness, the high computational cost of input tokens due to ever-growing trajectories remains a significant efficiency concern. Efficiency has been largely overlooked in existing studies and agent products, and this paper addresses this gap by introducing an inference-time trajectory reduction approach that reduces computational costs. By analyzing existing agent trajectories, we demonstrate that useless, redundant, and expired information is widespread across trajectories. Such waste can be identified and reduced without compromising the agent's performance. We propose a simple yet effective trajectory reduction approach, AgentDiet, which automatically removes such waste during agent execution. We implement AgentDiet on a top-performing coding agent, and our evaluation on two LLMs and two benchmarks shows that AgentDiet can reduce input tokens by 39.9%-59.7% and the total computational cost by 21.1%-35.9%, while maintaining the same agent performance. These results indicate that inference-time trajectory reduction is a promising direction for agent systems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。