agents.planning.p_and_e.modelsΒΆ

Models for Plan and Execute Agent System.

This module defines the data models for planning, execution, and replanning in the Plan and Execute agent architecture.

ClassesΒΆ

Act

Action to perform - either respond with answer or continue with plan.

ExecutionResult

Result from executing a single step.

Plan

Complete execution plan with steps and metadata.

PlanStep

Individual step in an execution plan.

ReplanDecision

Decision on whether to replan or provide final answer.

Response

Response to user with final answer.

StepStatus

Status of a plan step.

StepType

Type of plan step.

Module ContentsΒΆ

class agents.planning.p_and_e.models.Act(/, **data)ΒΆ

Bases: pydantic.BaseModel

Action to perform - either respond with answer or continue with plan.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

property is_final_response: boolΒΆ

Check if this is a final response.

Return type:

bool

property is_plan: boolΒΆ

Check if this is a plan to execute.

Return type:

bool

class agents.planning.p_and_e.models.ExecutionResult(/, **data)ΒΆ

Bases: pydantic.BaseModel

Result from executing a single step.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

to_prompt_format()ΒΆ

Format result for inclusion in prompts.

Return type:

str

class agents.planning.p_and_e.models.Plan(/, **data)ΒΆ

Bases: pydantic.BaseModel

Complete execution plan with steps and metadata.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

get_step(step_id)ΒΆ

Get a specific step by ID.

Parameters:

step_id (int)

Return type:

PlanStep | None

serialize_datetime(dt)ΒΆ

Serialize datetime fields to ISO format.

Parameters:

dt (datetime.datetime)

Return type:

str

to_prompt_format()ΒΆ

Format plan for inclusion in prompts.

Return type:

str

update_step_status(step_id, status, result=None, error=None)ΒΆ

Update the status of a specific step.

Parameters:
Return type:

bool

update_total_steps()ΒΆ

Ensure total_steps matches actual step count.

Return type:

Plan

classmethod validate_dependencies(steps)ΒΆ

Ensure dependencies reference valid step IDs.

Parameters:

steps (list[PlanStep])

Return type:

list[PlanStep]

classmethod validate_step_ids(steps)ΒΆ

Ensure step IDs are sequential starting from 1.

Parameters:

steps (list[PlanStep])

Return type:

list[PlanStep]

property completed_steps: list[PlanStep]ΒΆ

Get all completed steps.

Return type:

list[PlanStep]

property failed_steps: list[PlanStep]ΒΆ

Get all failed steps.

Return type:

list[PlanStep]

property has_failures: boolΒΆ

Check if any steps have failed.

Return type:

bool

property is_complete: boolΒΆ

Check if all steps are completed.

Return type:

bool

model_configΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property next_step: PlanStep | NoneΒΆ

Get the next step ready for execution.

Return type:

PlanStep | None

property pending_steps: list[PlanStep]ΒΆ

Get all pending steps.

Return type:

list[PlanStep]

property progress_percentage: floatΒΆ

Calculate completion percentage.

Return type:

float

class agents.planning.p_and_e.models.PlanStep(/, **data)ΒΆ

Bases: pydantic.BaseModel

Individual step in an execution plan.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

serialize_datetime(dt)ΒΆ

Serialize datetime fields to ISO format.

Parameters:

dt (datetime.datetime | None)

Return type:

str | None

to_prompt_format()ΒΆ

Format step for inclusion in prompts.

Return type:

str

property execution_time: float | NoneΒΆ

Calculate execution time in seconds.

Return type:

float | None

property is_ready: boolΒΆ

Check if step is ready to execute (all dependencies completed).

Return type:

bool

model_configΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class agents.planning.p_and_e.models.ReplanDecision(/, **data)ΒΆ

Bases: pydantic.BaseModel

Decision on whether to replan or provide final answer.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

validate_decision_fields()ΒΆ

Ensure required fields are present based on decision.

Return type:

ReplanDecision

class agents.planning.p_and_e.models.Response(/, **data)ΒΆ

Bases: pydantic.BaseModel

Response to user with final answer.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class agents.planning.p_and_e.models.StepStatusΒΆ

Bases: str, enum.Enum

Status of a plan step.

Initialize self. See help(type(self)) for accurate signature.

class agents.planning.p_and_e.models.StepTypeΒΆ

Bases: str, enum.Enum

Type of plan step.

Initialize self. See help(type(self)) for accurate signature.