| """Planner output schemas — the `TaskList` contract. |
| |
| The planner emits exactly one `TaskList`: a DAG of typed tasks, each an ordered |
| chain of fully-specified tool calls. This is the static plan the TaskRunner |
| executes verbatim. There is no replanning (INV-6), so there are no |
| `ReplanRequest` / `ReplanResponse` schemas. |
| |
| See AGENT_ARCHITECTURE_CONTEXT_new.md §7.3. |
| """ |
|
|
| from __future__ import annotations |
|
|
| import re |
| from typing import Any, Literal |
|
|
| from pydantic import BaseModel, Field |
|
|
| |
| |
| |
| |
| PLACEHOLDER_RE = re.compile(r"\$\{(t[^}]+)\}") |
|
|
| CrispStage = Literal[ |
| "data_understanding", |
| "data_preparation", |
| "modeling", |
| "evaluation", |
| ] |
|
|
|
|
| class ToolCall(BaseModel): |
| """One call to a registry tool with concrete, fully-specified arguments. |
| |
| `tool` must exist in the ToolRegistry. `args` is validated against the |
| tool's input_schema; it may contain "${t<id>}" placeholders that the |
| TaskRunner resolves from an upstream task's output at execution time. |
| """ |
|
|
| tool: str |
| args: dict[str, Any] = Field(default_factory=dict) |
|
|
|
|
| class Task(BaseModel): |
| id: str |
| stage: CrispStage |
| objective: str |
| tool_calls: list[ToolCall] = Field(..., min_length=1) |
| expected_output: str |
| success_criteria: str |
| depends_on: list[str] = Field(default_factory=list) |
| estimated_cost: Literal["low", "medium", "high"] = "low" |
|
|
|
|
| class TaskList(BaseModel): |
| plan_id: str |
| goal_restated: str |
| assumptions: list[str] = Field(default_factory=list) |
| open_questions: list[str] = Field(default_factory=list) |
| tasks: list[Task] = Field(default_factory=list) |
| |
| |
| |
| |
| |
| |
| infeasible_reason: str | None = Field( |
| None, |
| description=( |
| "Set ONLY when the question cannot be answered from the catalog: no " |
| "column plausibly holds the requested measure or entity. State what " |
| "is missing and the nearest data that IS available. Leave tasks " |
| "empty when set." |
| ), |
| ) |
|
|