Skip to content

API Reference parrot.tools.execution_plan.planner

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.execution_plan.planner

View source

PlanPlanner — objective mode: one structured LLM call authors an ExecutionPlan, with at most one bounded repair round on validation failure (spec §3 Module 4).

resolve_planner_client accepts the exact same planner_llm formats bots accept for llm/secondary_llm (ModelSwitchingMixin.secondary_llm, model_switching.py:92): a "provider:model" string, an AbstractClient subclass or instance, or a model_config dict. There is no implicit default model anywhere in this module — objective mode without a configured planner_llm is a structural error the toolkit (TASK-2184) raises before PlanPlanner is ever constructed.

Parsing is done here rather than through AbstractClient.ask(structured_ output=...): that base-class path silently falls back to returning the raw response text on a parse/validation failure (see AbstractClient._parse_structured_output), which would hide exactly the failures a repair round needs to detect. Instead the schema is embedded in the prompt and the response is parsed/validated here, raising a typed :class:PlanAuthoringError on failure.

Class PlanAuthoringError

Raised when a planner response cannot be parsed into an ExecutionPlan.

Class PlanPlanner

Authors/repairs an :class:ExecutionPlan via exactly one LLM call per round.

Parameter Type Default Description
planner_llm Union[str, Dict[str, Any], Type[AbstractClient], AbstractClient] See :func:resolve_planner_client.
catalog Sequence[ToolCatalogEntry] The allowlist-scoped catalog (TASK-2182's build_catalog) embedded in every prompt.
delegate_safe_tools Optional[Sequence[str]] None Tool names safe for delegate nodes. None disables delegate rules and leaves prompts unchanged.
delegate_max_tools int 5 Maximum tools a delegate node may choose from.

Attributes:

Attribute Type Description
client The resolved planner client.
catalog List[ToolCatalogEntry] Allowlist-scoped tool catalog embedded in every prompt.

Method PlanPlanner.author

Author a plan for objective in one LLM call.

author(objective: str) -> ExecutionPlan

Parameter Type Default Description
objective str The natural-language objective to plan for.

Returns: ExecutionPlan — The parsed :class:ExecutionPlan (not yet validated against a live ToolManager — the caller runs validate_plan).

Raises:

  • PlanAuthoringError — If the response is not valid JSON, or does not validate as an ExecutionPlan.

Method PlanPlanner.repair

Re-prompt once with report's text embedded verbatim.

repair(plan_json: Dict[str, Any], report: ValidationReport) -> ExecutionPlan

Parameter Type Default Description
plan_json Dict[str, Any] The invalid plan's JSON document.
report ValidationReport The validation failure to repair from.

Returns: ExecutionPlan — The corrected :class:ExecutionPlan.

Raises:

  • PlanAuthoringError — If the repaired response still fails to parse/validate.

Method PlanPlanner.replan

Make one planner call for replacements only; raise on malformed output.

replan(plan: ExecutionPlan, manifest: ExecutionManifest, *, eligible_node_ids: FrozenSet[str]) -> PlanDelta

Parameter Type Default Description
plan ExecutionPlan The original, previously-accepted plan.
manifest ExecutionManifest The failed run's bounded manifest (per-node statuses/errors only).
eligible_node_ids FrozenSet[str] Node ids the planner is allowed to replace.

Returns: PlanDelta — The parsed :class:PlanDelta, restricted to eligible_node_ids.

Raises:

  • PlanAuthoringError — If the response is not valid JSON, does not validate as a PlanDelta, or names a non-eligible node id.

Method PlanPlanner.repair_delta

Make one structural correction call, retaining runtime delta restrictions.

repair_delta(delta_json: Dict[str, Any], report: ValidationReport, *, plan: ExecutionPlan, eligible_node_ids: FrozenSet[str]) -> PlanDelta

Parameter Type Default Description
delta_json Dict[str, Any] The invalid delta's JSON document.
report ValidationReport The validation failure to repair from.
plan ExecutionPlan The original, previously-accepted plan.
eligible_node_ids FrozenSet[str] Node ids the planner is allowed to replace.

Returns: PlanDelta — The corrected :class:PlanDelta, restricted to eligible_node_ids.

Raises:

  • PlanAuthoringError — If the corrected response still fails to parse/validate.

Function resolve_planner_client

Resolve planner_llm into a live, not-yet-entered AbstractClient.

resolve_planner_client(planner_llm: Union[str, Dict[str, Any], Type[AbstractClient], AbstractClient]) -> AbstractClient

Parameter Type Default Description
planner_llm Union[str, Dict[str, Any], Type[AbstractClient], AbstractClient] "provider:model" string, an AbstractClient subclass or instance, or a model_config dict (same keys as AbstractBot._parse_model_config: name/llm/ provider, model, temperature, top_k, top_p, max_tokens, plus any extra client kwargs).

Returns: AbstractClient — A live AbstractClient.

Raises:

  • ValueError — If planner_llm is none of the accepted formats, or a dict/string names an unsupported provider.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally