MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / PlanGenerator

Class PlanGenerator

src/harness/agentic_loop/plan_generator.py:14–204  ·  view source on GitHub ↗

Generate AgentSPEX YAML workflow plans for a given task. Uses a (typically cheap) LLM to produce YAML, validates it parses, and writes it to disk. Retries once on parse failure with error feedback.

Source from the content-addressed store, hash-verified

12
13
14class PlanGenerator:
15 """Generate AgentSPEX YAML workflow plans for a given task.
16
17 Uses a (typically cheap) LLM to produce YAML, validates it parses,
18 and writes it to disk. Retries once on parse failure with error feedback.
19 """
20
21 def __init__(
22 self,
23 llm_client: LLMClient,
24 model: str,
25 plans_dir: Path,
26 available_tool_names: list[str],
27 workflow_language_guide: str,
28 temperature: float = 0.2,
29 tool_briefs: dict[str, dict] | None = None,
30 executor_model: str | None = None,
31 ):
32 self.llm_client = llm_client
33 self.model = model
34 self.plans_dir = plans_dir
35 self.available_tool_names = available_tool_names
36 self.temperature = temperature
37 self._tool_briefs = tool_briefs or {}
38 self._system_prompt = get_plan_generator_system_prompt(
39 available_tool_names,
40 workflow_language_guide,
41 executor_model=executor_model,
42 )
43 self.plans_dir.mkdir(parents=True, exist_ok=True)
44
45 def generate(
46 self,
47 task_id: str,
48 task_description: str,
49 context_summary: Optional[str] = None,
50 hints: Optional[str] = None,
51 recommended_tools: Optional[list[str]] = None,
52 ) -> Path:
53 """Generate a YAML plan for the given task.
54
55 Args:
56 task_id: Identifier used for the output filename (e.g. "task_001").
57 task_description: What the task should accomplish.
58 context_summary: Optional summary of relevant context from the
59 orchestrator's conversation so far.
60 hints: Optional hints for the plan generator (e.g. preferred
61 structure, tool preferences).
62 recommended_tools: Optional list of MCP tool names pre-selected
63 by the orchestrator. When provided, the plan generator is
64 instructed to use ONLY these tools. The orchestrator (more
65 capable model with full tool schemas) makes the tool selection
66 decision; the plan generator focuses on workflow structure.
67
68 Returns:
69 Path to the generated YAML file.
70
71 Raises:

Callers 1

_setupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected