FoundationAgents/MetaGPT · error · ValueError
Rollouts must be greater than 2 if there is no tree to load
Error message
Rollouts must be greater than 2 if there is no tree to load
What it means
Raised by MCTS tree search when no tree could be loaded from disk and the requested rollout count is too small: rollouts is decremented by 2 because two rollouts are consumed to build the initial tree (simulate root + expand_and_simulate), and a negative remainder is rejected. Effectively rollouts must be >= 2 (message says greater than 2; rollouts < 2 after subtracting triggers it).
Source
Thrown at metagpt/ext/sela/search/tree_search.py:434
rollouts = args.rollouts
from_scratch = args.from_scratch
role, root = initialize_di_root_node(state, reflection=reflection)
self.root_node = root
self.instruction_generator = InstructionGenerator(
state=state, use_fixed_insights=self.use_fixed_insights, from_scratch=from_scratch
)
await self.instruction_generator.initialize()
tree_loaded = False
if load_tree:
tree_loaded = self.load_tree()
mcts_logger.log("MCTS", f"Number of simulations: {self.get_num_simulations()}")
mcts_logger.log("MCTS", f"Tree loaded: {tree_loaded}")
if not tree_loaded:
rollouts -= 2 # 2 rollouts for the initial tree
if rollouts < 0:
raise ValueError("Rollouts must be greater than 2 if there is no tree to load")
self.children[root] = []
reward = await self.simulate(root, role)
self.backpropagate(root, reward)
node, reward = await self.expand_and_simulate(root)
# self.backpropagate(node, reward)
self.save_node_order(root.id)
self.save_node_order(node.id)
else:
root = self.root_node
self.load_node_order()
for _ in range(rollouts): # number of rollouts
mcts_logger.log("MCTS", f"Start the next rollout {_+1}")
node = self.select(root)
if node.is_terminal():
if node.raw_value == 0:
reward = await self.simulate(node)
else:View on GitHub (pinned to 11cdf466d0)
Solutions
- Increase --rollouts to at least 3 (2 are consumed for initial tree construction)
- Verify the tree file path in args so a previously saved tree is actually loaded
- For quick tests, keep rollouts small but >= 3 on a fresh tree
Example fix
# before --rollouts 1 # after --rollouts 10
Defensive patterns
Strategy: validation
Validate before calling
MIN_ROLLOUTS = 3
if not tree_exists(load_tree_path) and rollouts < MIN_ROLLOUTS:
raise SystemExit("increase --rollouts to >= 3 for a fresh tree") Prevention
- Keep rollouts >= 3 for cold-start searches
- Persist and correctly point to the saved tree between runs so rollouts are not re-spent on initialization
When it happens
Trigger: Starting a fresh search (no saved tree JSON in the tree save path) with --rollouts 0 or 1; or load_tree failing silently (missing/corrupt tree file) while a small rollout count is used.
Common situations: Smoke-testing with a tiny rollout count; wrong tree save/load directory so an existing tree is not found; deleted tree files.
Related errors
- please check MilvusConnection, uri must be set.
- Dataset {dataset_name} not found in config file. Available d
- Dataset {task_name} not found in config file. Available data
- Number of classes {num_classes} not supported
- Target column not provided
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/e1a92eb0d7194865.
Report an issue: GitHub.