The exceptional capabilities of large language models (LLMs) have substantially accelerated the rapid rise and widespread adoption of agents. Recent studies have demonstrated that generating Python code to consolidate LLM-based agents' actions into a unified action space (CodeAct) is a promising approach for developing real-world LLM agents. However, this step-by-step code generation approach often lacks consistency and robustness, leading to instability in agent applications, particularly for complex reasoning and out-of-domain tasks. In this paper, we propose a novel approach called Tree-of-Code (ToC) to tackle the challenges of complex problem planning and execution with an end-to-end mechanism. By integrating key ideas from both Tree-of-Thought and CodeAct, ToC combines their strengths to enhance solution exploration. In our framework, each final code execution result is treated as a node in the decision tree, with a breadth-first search strategy employed to explore potential solutions. The final outcome is determined through a voting mechanism based on the outputs of the nodes.
翻译:大型语言模型(LLM)的卓越能力极大地加速了智能体的迅速崛起和广泛应用。近期研究表明,通过生成Python代码将基于LLM的智能体行为整合到统一行动空间(CodeAct),是开发现实世界LLM智能体的一种有效途径。然而,这种逐步生成代码的方法往往缺乏一致性和鲁棒性,导致智能体应用的不稳定性,特别是在复杂推理和领域外任务中。本文提出了一种称为代码树(ToC)的新方法,通过端到端机制应对复杂问题规划与执行的挑战。通过融合思维树与CodeAct的核心思想,ToC结合了两者的优势以增强解决方案的探索能力。在我们的框架中,每个最终代码执行结果被视为决策树中的一个节点,并采用广度优先搜索策略来探索潜在解决方案。最终结果通过基于节点输出的投票机制确定。