记住,不要重读:用于令牌高效自主实验的有状态ReAct智能体
Remember, Don't Re-read: Stateful ReAct Agents for Token-Efficient Autonomous Experimentation
AI总结:
提出基于LangGraph的有状态ReAct智能体,通过持久化状态和固定大小对话窗口,将自主实验的令牌成本从O(n²)降至O(1),在超参数调优和代码优化任务中分别减少90%和52%的令牌消耗。
摘要:
自动研究模式通过让大语言模型(LLM)迭代修改代码来优化目标指标,从而实现自主实验。然而,其无状态设计在每次迭代中从头重建实验上下文,导致每次迭代的令牌成本为$O(n)$,总成本为$O(n^{2})$。本文将该模式重新表述为使用LangGraph的有状态ReAct智能体,其中类型化的持久化状态通过工具调用接口跨迭代传递实验历史。评估了两个基准:超参数调优(15次迭代,每次迭代观察数据小)和代码性能优化(40次迭代,每次迭代观察数据大,包含完整源代码和基准测试结果)。在超参数调优中,有状态智能体消耗的令牌减少90%(2,492 vs. 24,465)。在代码优化中,有状态智能体消耗的令牌减少52%(627K vs. 1,275K),同时在两项任务上实现了相当的优化质量。令牌减少是结构性的:无状态智能体以每次迭代$O(n)$的成本重读完整历史,而有状态智能体在固定大小的对话窗口内以$O(1)$成本运行。本文详细描述了该架构,使从业者能够为其自己的工作流程实现有状态自动研究智能体。
英文摘要:
The autoresearch pattern enables autonomous experimentation by having a large language model (LLM) iteratively modify code to optimize a target metric. Its stateless design, however, reconstructs experimental context from scratch at every iteration, incurring $O(n)$ token cost per iteration and $O(n^{2})$ total. This work reformulates the pattern as a stateful ReAct agent using LangGraph, where typed persistent state carries experimental history across iterations via a tool-calling interface. Two benchmarks are evaluated: hyperparameter tuning (15 iterations, small per-iteration observations) and code performance optimization (40 iterations, large per-iteration observations containing full source code and benchmark results). On hyperparameter tuning, the stateful agent consumes 90\% fewer tokens (2{,}492 vs.\ 24{,}465). On code optimization, the stateful agent consumes 52\% fewer tokens (627K vs.\ 1{,}275K) while achieving comparable optimization quality on both tasks. The token reduction is structural: the stateless agent re-reads the full history at $O(n)$ cost per iteration, while the stateful agent operates within a fixed-size conversation window at $O(1)$ cost. This paper describes the architecture in sufficient detail for practitioners to implement a stateful autoresearch agent for their own workflows.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。