TreeFlex: Agents Navigating Their Own Search Trees

Dongzhuo Li, Fangzhou Cheng, Weiwei Li, Kevin Han, Haixu Ma, Zhongchang Sun, Ruiyi Li, Serena Li, Xiangjun Fan, Lizhu Zhang, Yuandong TianarXiv 2026

TL;DR

TreeFlex is a new framework that allows LLM agents to autonomously manage their own search trees, moving beyond the limitations of linear conversation histories. By splitting the agent into Reflection (global navigation) and Execution (local task work) roles and training them via a tree-aware RL objective, TreeFlex significantly outperforms standard agents on complex research and software engineering benchmarks.

What Problem Does This Paper Address?

Standard autonomous agents (like those using the ReAct pattern) typically operate within a single, linear context. As they tackle long-horizon tasks, this context fills up with failed attempts, irrelevant observations, and stale information. This "context bloat" makes it increasingly difficult for the model to focus on relevant evidence.

While tree-search methods (like Tree of Thoughts) exist to explore multiple paths, they often rely on rigid, hand-coded rules (like DFS or BFS) or isolated node-scoring heuristics that don't account for the global state of the search. The authors argue that an agent should be able to decide for itself when to deepen a current line of thought, branch out into a new idea, or backtrack to a previous state based on what it has learned so far.

Methods

TreeFlex introduces a system where a single language model plays two distinct roles:

  • Reflection: This role has a "global view" of the search tree. It sees the original task and a collection of short summary "cards" for every node explored so far. It decides which node to resume and provides a specific instruction for the next step.
  • Execution: This role has a "path view." The system restores the specific environment state (like a git repository snapshot) and the conversation history leading to the chosen node. Execution performs the actual work (searching, coding, etc.) until it either saves a new checkpoint (creating a new node) or commits a final solution.
A conceptual overview of the TreeFlex search process, showing the interplay between the global Reflection view and the local Execution path.

To train this behavior, the authors adapted Group Relative Policy Optimization (GRPO). They treat an entire tree search as a single rollout. To ensure the model learns correctly from non-linear histories, they use Causal Blocks: the model is only trained on the specific tokens it generated, using the exact context it saw at that moment, even if that context is later "restored" from an earlier point in the tree.

The tree-aware GRPO training process, illustrating how rollouts are divided into causal blocks for Reflection and Execution.

Datasets

The authors evaluated TreeFlex across two demanding domains:

  1. Deep Research: Using BrowseComp-Plus, which requires agents to synthesize information across multiple documents to answer complex questions.
  2. Agentic Software Engineering (SWE): Using SWE-bench Verified, where agents must resolve real-world GitHub issues. Training for this domain was conducted on SWE-Gym.

Key Insights and Ideas

  • Policy-Directed Navigation: Unlike traditional search algorithms, TreeFlex doesn't use a fixed heuristic. The agent learns a navigation policy, allowing it to adapt its search strategy to the specific difficulty of the question.
  • Context Hygiene: By only showing the Execution role the relevant path, TreeFlex maintains a high "signal-to-noise" ratio in the model's context window, even during very long tasks.
  • Evidence-Directed Backtracking: A key "aha" moment is the agent's ability to recognize when a later discovery invalidates a previous assumption, prompting it to return to an earlier node to try a different branch.
A case study showing the agent proposing a solution, finding conflicting evidence in a sibling branch, and then returning to the original path to correct the error.

Key Results

TreeFlex demonstrated substantial gains over both flat ReAct agents and "FoldAgent" (a state-of-the-art context-compressing agent):

  • Deep Research: On BrowseComp-Plus, a 4B TreeFlex model achieved 48.8% accuracy, significantly higher than flat ReAct (41.5%) and FoldAgent (42.8%).
  • Software Engineering: On SWE-bench Verified, TreeFlex resolved 54.9% of tasks, compared to 43.3% for FoldAgent.
  • Difficulty Scaling: The performance gap is widest on "Hard" questions, where TreeFlex's ability to explore and backtrack is most critical. On hard research questions, TreeFlex reached 13.4% accuracy, while flat ReAct managed only 3.9%.
Comparison of accuracy across different question difficulty levels, showing TreeFlex's dominance on medium and hard tasks.

Limitations and Future Work

  • Inference Cost: TreeFlex is more computationally expensive than linear agents, performing more retrieval calls and generating more tokens per task.
  • Latency: Because search segments are executed sequentially, the total time to reach a solution is higher.
  • Scale: The experiments were conducted on relatively small models (4B and 9B). The authors suggest that training at a larger scale with more data could further unlock the potential of learned search policies.
  • Efficiency Rewards: Future iterations could incorporate rewards that explicitly penalize excessive token usage or redundant tool calls to encourage more efficient search paths.

Summary updated

BibTeX
@misc{li2026treeflex,
  author = {Dongzhuo Li and Fangzhou Cheng and Weiwei Li and Kevin Han and Haixu Ma and Zhongchang Sun and Ruiyi Li and Serena Li and Xiangjun Fan and Lizhu Zhang and Yuandong Tian},
  title = {{TreeFlex: Agents Navigating Their Own Search Trees}},
  year = {2026},
  eprint = {2610.20334},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.20334},
}
Figure