@@ -55,15 +55,15 @@ def __init__(self,
5555 action_space , train_tasks , * args , ** kwargs )
5656 self ._offline_dataset = Dataset ([])
5757 self ._online_trajectories : List [LowLevelTrajectory ] = []
58- if option_model is not None :
59- self ._option_model = option_model
60- else :
61- self ._option_model = create_option_model (CFG .option_model_name )
58+ self ._option_model : Optional [_OptionModelBase ] = (
59+ option_model if option_model is not None else
60+ self ._create_planner_option_model ())
6261 # Let the option model terminate Wait on atom change using the
6362 # approach's predicates (which may include invented ones). Looked
6463 # up lazily so the lambda picks up predicates invented after
6564 # __init__.
66- if CFG .wait_option_terminate_on_atom_change :
65+ if self ._option_model is not None and \
66+ CFG .wait_option_terminate_on_atom_change :
6767 cast ( # pylint: disable=protected-access
6868 Any , self ._option_model )._abstract_function = (
6969 lambda s : utils .abstract (s , self ._get_all_predicates ()))
@@ -119,6 +119,27 @@ def _get_all_trajectories(self) -> List[LowLevelTrajectory]:
119119 """Return all trajectories (offline + online)."""
120120 return self ._offline_dataset .trajectories + self ._online_trajectories
121121
122+ def _create_planner_option_model (self ) -> Optional [_OptionModelBase ]:
123+ """Build the option model the planner tests plans against.
124+
125+ Honors two CFG knobs:
126+
127+ * ``agent_planner_use_simulator`` -- when False, returns ``None``
128+ so the agent gets no ``test_option_plan`` rollouts and must
129+ plan open-loop from data + LLM reasoning (the model-free
130+ baseline).
131+ * ``agent_planner_use_base_simulator`` -- when True (and a
132+ simulator is used), wraps the *base* env
133+ (``skip_process_dynamics=True``) so the planner is denied the
134+ delayed ``_domain_specific_step`` dynamics; otherwise wraps the
135+ real env.
136+ """
137+ if not CFG .agent_planner_use_simulator :
138+ return None
139+ return create_option_model (
140+ CFG .option_model_name ,
141+ skip_process_dynamics = CFG .agent_planner_use_base_simulator )
142+
122143 # ------------------------------------------------------------------ #
123144 # AgentSessionMixin hooks
124145 # ------------------------------------------------------------------ #
@@ -217,8 +238,12 @@ def _get_all_trajectories(self) -> List[LowLevelTrajectory]:
217238
218239 def _get_agent_system_prompt (self ) -> str :
219240 use_scratchpad = CFG .agent_planner_use_scratchpad
220- use_visualize = CFG .agent_planner_use_visualize_state
221- use_annotate = CFG .agent_planner_use_annotate_scene
241+ # visualize_state / annotate_scene render a live env, so they are
242+ # only available when the planner has a simulator.
243+ use_visualize = (CFG .agent_planner_use_simulator
244+ and CFG .agent_planner_use_visualize_state )
245+ use_annotate = (CFG .agent_planner_use_simulator
246+ and CFG .agent_planner_use_annotate_scene )
222247
223248 sections = [self ._SYSTEM_PROMPT_BASE ]
224249
@@ -317,13 +342,18 @@ def _get_sandbox_reference_files(self) -> Dict[str, str]:
317342
318343 def _get_solve_tool_names (self ) -> Optional [List [str ]]:
319344 tools = [
320- "inspect_options" , "inspect_trajectories" , "inspect_train_tasks" ,
321- "test_option_plan"
345+ "inspect_options" , "inspect_trajectories" , "inspect_train_tasks"
322346 ]
323- if CFG .agent_planner_use_annotate_scene :
324- tools .append ("annotate_scene" )
325- if CFG .agent_planner_use_visualize_state :
326- tools .append ("visualize_state" )
347+ # The remaining tools all require a simulator / live env:
348+ # test_option_plan rolls plans out through the option model, and
349+ # visualize_state / annotate_scene render env states. None are
350+ # offered when the planner has no simulator.
351+ if CFG .agent_planner_use_simulator :
352+ tools .append ("test_option_plan" )
353+ if CFG .agent_planner_use_annotate_scene :
354+ tools .append ("annotate_scene" )
355+ if CFG .agent_planner_use_visualize_state :
356+ tools .append ("visualize_state" )
327357 return tools
328358
329359 # ------------------------------------------------------------------ #
@@ -524,6 +554,16 @@ def _build_solve_prompt(self, task: Task) -> str:
524554{ task .goal_nl }
525555"""
526556
557+ if CFG .agent_planner_use_simulator :
558+ instructions_intro = (
559+ "Use your available tools to inspect the environment and "
560+ "test your plan before committing to it." )
561+ else :
562+ instructions_intro = (
563+ "You do NOT have a simulator to test plans against. Inspect "
564+ "the trajectory data and reason carefully about the dynamics, "
565+ "then commit to your best open-loop plan." )
566+
527567 prompt = f"""You are solving a task. \
528568 Generate an option plan to achieve the goal.
529569{ goal_nl_section }
@@ -543,7 +583,7 @@ def _build_solve_prompt(self, task: Task) -> str:
543583{ chr (10 ).join (option_strs )}
544584{ traj_summary } { tools_str }
545585## Instructions
546- Use your available tools to inspect the environment and test your plan before committing to it.
586+ { instructions_intro }
547587
548588Based on the task information and any past trajectory data, output an option plan to achieve the goal.
549589
0 commit comments