Load and execute a YAML plan through the Interpreter. Args: plan_path: Path to the verified YAML plan file. model: Optional model override for execution. If provided, takes precedence over the plan's config.model. If not provided, the
(
self,
plan_path: Path,
model: Optional[str] = None,
)
| 103 | self._parser = YAMLTaskParser() |
| 104 | |
| 105 | def execute( |
| 106 | self, |
| 107 | plan_path: Path, |
| 108 | model: Optional[str] = None, |
| 109 | ) -> ExecutionResult: |
| 110 | """Load and execute a YAML plan through the Interpreter. |
| 111 | |
| 112 | Args: |
| 113 | plan_path: Path to the verified YAML plan file. |
| 114 | model: Optional model override for execution. If provided, |
| 115 | takes precedence over the plan's config.model. If not |
| 116 | provided, the plan's config.model is used (or the |
| 117 | EffectiveArgs default of gpt-4.1-mini). |
| 118 | |
| 119 | Returns: |
| 120 | ExecutionResult with the output text, success flag, step |
| 121 | counts, any errors, the parsed plan data (for health |
| 122 | assessment), and token/cost usage. |
| 123 | |
| 124 | Raises: |
| 125 | FileNotFoundError: If the plan file doesn't exist. |
| 126 | ValueError: If the plan contains invalid YAML or is missing |
| 127 | required fields (name, goal, workflow). |
| 128 | """ |
| 129 | plan_path = Path(plan_path) |
| 130 | |
| 131 | # ── 1. Load and parse YAML ─────────────────────────────────────── |
| 132 | yaml_data = self._parser.load_task(str(plan_path)) |
| 133 | task_name = yaml_data["name"] |
| 134 | goal = yaml_data["goal"] |
| 135 | workflow = yaml_data["workflow"] |
| 136 | yaml_config = yaml_data.get("config", {}) or {} |
| 137 | |
| 138 | # ── 2. Load submodules if declared in the plan ─────────────────── |
| 139 | submodule_tools, submodule_registry = load_submodule_tools_for_yaml( |
| 140 | yaml_data, str(plan_path) |
| 141 | ) |
| 142 | |
| 143 | # ── 3. Build EffectiveArgs ─────────────────────────────────────── |
| 144 | # Precedence: explicit model override > plan's config.model > default |
| 145 | # |
| 146 | # EffectiveArgs.with_yaml_config() applies YAML config on top of base, |
| 147 | # so we build base first, apply YAML config, then re-apply explicit |
| 148 | # model if provided (since YAML config would have overridden it). |
| 149 | base_args = EffectiveArgs(workflow_file=str(plan_path)) |
| 150 | effective_args = ( |
| 151 | base_args.with_yaml_config(yaml_config) if yaml_config else base_args |
| 152 | ) |
| 153 | if model: |
| 154 | # Re-create with explicit model on top of yaml-configured values |
| 155 | effective_args = EffectiveArgs( |
| 156 | model=model, |
| 157 | api_base=effective_args.api_base, |
| 158 | max_tokens_per_step=effective_args.max_tokens_per_step, |
| 159 | max_tool_calls_per_step=effective_args.max_tool_calls_per_step, |
| 160 | temperature=effective_args.temperature, |
| 161 | model_kwargs=effective_args.model_kwargs, |
| 162 | context_threshold=effective_args.context_threshold, |
no test coverage detected