TreeFlex: Agents Navigating Their Own Search Trees
Organizations: Meta AI
Abstract
A ReAct-style agent accumulates observations, intermediate results, and failed attempts in a single context. As this context grows, stale and off-path information consumes its limited capacity and obscures relevant evidence, making focused reasoning increasingly difficult. We introduce TreeFlex, a framework in which the agent's own policy decides where to search. The agent records each intermediate state, with a short summary, as a node in a search tree maintained by the harness. The policy is a single language model that acts in two roles. In the Reflection role, it has a global view of the tree through these summaries and picks a node to resume, together with an instruction. In the Execution role, the harness restores the path that led to that node, and the model carries out the instruction with the usual task tools until it saves a new node or proposes a solution, which Reflection then approves or sends back to another node. Through these choices, the policy decides whether to deepen the current line, branch from or revisit an earlier state, verify a proposal, or stop, without a fixed traversal order or a score for each node. We train navigation, task actions, checkpointing, and proposal review jointly with a tree-aware adaptation of GRPO, using task-level outcome rewards augmented by process rewards. After small-scale RL of a 4B model, with the same active-context limit for all methods, TreeFlex reaches 48.8% accuracy on a challenging deep-research benchmark, versus 41.5% for flat ReAct and 42.8% for FoldAgent, and its Pass@8 is about ten points higher than either. On SWE-bench Verified, with all three systems trained with RL from the same 9B model, TreeFlex resolves 54.9% of tasks, versus 43.3% for FoldAgent and 45.2% for its step-wise variant.
Figures & tables
| Tool | Role | What it does |
| navigate(node, instruction) | Reflection | Choose a node to resume and write an instruction for the next segment. Creates no node. |
| Domain tools | Execution | Work on the task, such as retrieving documents or editing and testing code. |
| checkpoint(summary) | Execution | Save the current state as a new child of the node where the segment started, with summary as its card, and return the card to Reflection. |
| commit(solution) | Execution | Save the current state as a new child of the node where the segment started, holding a proposed final solution for Reflection to review. |
| approve_commit(node) | Reflection | Accept the proposed solution at node unchanged, which ends the search. |
| Quality (%) | Usage per rollout | |||||||
| Model | Method | Ctx. | Br./nav. | Mean@8 | Pass@8 | Gen. tokens | Searches | Reads |
| Qwen3-30B (base) | Flat ReAct | 32k | 0 | 42.6 | 55.3 | 584 | 3.1 | 3.7 |
| FoldAgent | 32k | 10 | 46.1 | 66.7 | 3,212 | 8.7 | 11.5 | |
| TreeFlex | 32k | 10 | 48.3 | 62.7 | 4,833 | 14.3 | 20.6 | |
| Qwen3-4B (base) | Flat ReAct | 32k | 0 | 36.2 | 56.0 | 1,082 | 2.4 | 2.3 |
| FoldAgent | 32k | 10 | 33.1 | 54.0 | 2,553 | 5.7 | 12.3 | |
| Resolved (%) | Usage per rollout | ||||
| System | RL | Mean@3 | Pass@3 | Turns | Minutes |
| FoldAgent | none | 31.7 | 44.0 | 34 | 5.0 |
| FoldGRPO | 43.3 | 57.8 | 49 | 6.4 | |
| FoldAgent , step-wise delegation prompt | none | 49.5 | 63.0 | 132 | 21.9 |
| FoldGRPO | 45.2 | 58.2 | 96 | 10.0 | |
| TreeFlex | none | 51.1 | 64.4 | 98 | 24.8 |
| Accuracy (%) | Tree behavior during training (%) | ||||||||
| Loss | Pen. | Val. | Mean@8 | Pass@8 | Branched | Root nav. | Ancestor nav. | Internal fork | |
| rollout (main) | 0 | no | 38.0 | 48.8 | 66.0 | 53 59 | 19 23 | 5 2 | 19 18 |
| block | 0 | no | 34.9 | 48.4 | 65.3 | 38 66 | 17 19 | 3 10 | 12 32 |
| rollout | 0.3 | no | 35.4 | 45.3 | 66.0 | 40 51 | 13 9 | 5 5 | 16 26 |
| token | 0.3 | no | 40.1 | 47.7 | 66.0 | 50 63 | 20 19 | 4 0 | 19 12 |
| token | 0 | no | 33.9 | 46.7 | 65.3 | 49 83 | 17 33 | 5 1 | 18 24 |
| Run | Step | Val. | Mean@3 | Pass@3 | Returns | |
| base model | – | 22.3 | 51.1 | 64.4 | – | 43.0 |
| token mean | 20 | 26.7 | 52.1 | 67.4 | 24.7 | |
| rollout mean | 25 | 28.7 | 54.9 | 68.0 | 12.2 |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Setting | TreeFlex | FoldAgent | Flat ReAct (32k) | Flat ReAct (254k) |
| Model and data | ||||
| Base model | Qwen3-4B-Instruct-2507 | |||
| Train / validation / test questions | 616 / 64 / 150 | |||
| Machines GPUs per machine | ||||
| Optimization | ||||
| Training steps | 50 | |||
| Metric | Comparison | Difference | 95% interval |
| Mean@8 | vs. flat ReAct | [3.50, 11.25] | |
| vs. FoldAgent | [1.67, 10.42] | ||
| Pass@8 | vs. flat ReAct | [4.00, 16.00] | |
| vs. FoldAgent | [4.67, 16.67] | ||
| Vote@8 | vs. flat ReAct vote@8 | [3.36, 14.97] | |
| vs. FoldAgent vote@8 | [ , 10.33] |
| Comparison | Difference | 95% interval |
| TreeFlex vs. FoldAgent , base models | [16.20, 22.73] | |
| TreeFlex vs. FoldAgent step-wise, base models | [ , 4.00] | |
| TreeFlex RL vs. FoldAgent RL | [9.00, 14.27] | |
| TreeFlex RL vs. FoldAgent step-wise RL | [7.07, 12.40] | |
| TreeFlex RL vs. its base model | [1.40, 6.27] | |
| FoldAgent RL vs. its base model | [9.00, 14.40] |
| System | RL | Resolved | Submitted and resolved | Submitted |
| FoldAgent | none | 31.7 | 3.7 | 3.9 |
| FoldGRPO | 43.3 | 13.4 | 17.4 | |
| FoldAgent , step-wise delegation prompt | none | 49.5 | 31.5 | 42.3 |
| FoldGRPO | 45.2 | 40.8 | 69.5 | |
| TreeFlex | none | 51.1 | 50.1 | 86.1 |
| tree-aware GRPO | 54.9 | 53.6 | 90.1 |
| Search queries | Distinct opened documents | Evidence read | |||||
| Method | Per rollout | Distinct, across 8 | Repeated | Per rollout | Distinct, across 8 | Per rollout | Across 8 |
| Flat ReAct | 3.4 | 21.3 | 21% | 2.0 | 5.3 | 19% | 34% |
| FoldAgent | 9.3 | 68.0 | 10% | 2.7 | 8.7 | 26% | 48% |
| TreeFlex | 20.7 | 153.2 | 6% | 5.2 | 16.0 | 34% | 59% |