Tree-of-Code: A Hybrid Approach for Robust Complex Task Planning and Execution
This paper introduces Tree-of-Code (ToC), a novel hybrid approach that integrates Tree-of-Thought and CodeAct to enhance the robustness and accuracy of large language model (LLM) agents in complex task planning and execution. ToC treats each final code execution result as a node in a decision tree, employing a breadth-first search strategy and a majority voting mechanism to determine outcomes. This method addresses issues of inconsistency and hallucination in step-by-step code generation, demonstrating improved stability and higher accuracy compared to existing methods. ✨
Article Points:
1
ToC combines Tree-of-Thought and CodeAct for robust LLM agent task execution.
2
It uses an end-to-end thought-code-execution pipeline for complex tasks.
3
ToC explores solutions via a decision tree with breadth-first search.
4
Final results are determined by majority voting on successfully executed nodes.
5
ToC enhances stability and accuracy, outperforming CodeAct and Tree-of-Thought.
6
The method integrates various LLMs without requiring fine-tuning.
Tree-of-Code: A Hybrid Approach for Robust Complex Task Planning and Execution
Hybrid Design

Integrates Tree-of-Thought

Combines CodeAct strengths

Core Mechanism

Decision tree structure

Breadth-first search

Majority voting for results

Process Stages

Thought & Code Generation

Code Execution

Execution-level Reflection

Key Contributions

Enhanced stability & accuracy

Flexible LLM integration

Improved problem-solving

Experimental Results

Outperforms CodeAct

Reduced interaction steps

Validated on M3ToolEval

Addresses Limitations

CodeAct inconsistency

LLM hallucinations

Limited code diversity