haive.agents.planning.models.base ================================= .. py:module:: haive.agents.planning.models.base .. autoapi-nested-parse:: Base models for the unified planning system. This module provides the foundation for a flexible planning system that can support various planning patterns including Plan-and-Execute, ReWOO, LLM Compiler, FLARE RAG, and recursive planning capabilities. Key Design Principles: 1. Composable: Different planning patterns can mix and match components 2. Extensible: Easy to add new step types and planning patterns 3. Type-safe: Comprehensive validation and type checking 4. Resource-aware: Built-in support for resource tracking and constraints Classes ------- .. autoapisummary:: haive.agents.planning.models.base.ActionStep haive.agents.planning.models.base.AdaptivePlan haive.agents.planning.models.base.BasePlan haive.agents.planning.models.base.BaseStep haive.agents.planning.models.base.ConditionalStep haive.agents.planning.models.base.DAGPlan haive.agents.planning.models.base.Dependency haive.agents.planning.models.base.DependencyType haive.agents.planning.models.base.ExecutionMode haive.agents.planning.models.base.ParallelStep haive.agents.planning.models.base.RecursiveStep haive.agents.planning.models.base.ResearchStep haive.agents.planning.models.base.SequentialPlan haive.agents.planning.models.base.StepMetadata haive.agents.planning.models.base.StepStatus haive.agents.planning.models.base.StepType Module Contents --------------- .. py:class:: ActionStep(/, **data) Bases: :py:obj:`BaseStep` Step that performs a specific action or tool call. 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. .. py:class:: AdaptivePlan(/, **data) Bases: :py:obj:`BasePlan` Plan that can adapt during execution (FLARE style). 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. .. py:method:: adapt(context) Adapt plan based on execution context. .. py:method:: should_adapt(context) Check if plan should adapt based on context. .. py:class:: BasePlan(/, **data) Bases: :py:obj:`pydantic.BaseModel` Base class for all planning patterns. This provides core planning functionality while allowing different planning strategies to extend and customize behavior. 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. .. py:method:: add_step(step) Add a step to the plan. .. py:method:: get_execution_order() Get steps organized by execution order (batches for parallel execution). .. py:method:: get_step(step_id) Get step by ID. .. py:method:: to_mermaid() Generate Mermaid diagram of plan. .. py:method:: to_prompt_format() Format plan for inclusion in prompts. .. py:method:: update_ready_steps() Update and return steps that are ready to execute. .. py:property:: completed_steps :type: list[AnyStep] Get completed steps. .. py:property:: failed_steps :type: list[AnyStep] Get failed steps. .. py:property:: has_failures :type: bool Check if any steps failed. .. py:property:: is_complete :type: bool Check if plan is complete. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:property:: pending_steps :type: list[AnyStep] Get pending steps. .. py:property:: progress_percentage :type: float Calculate completion percentage. .. py:property:: ready_steps :type: list[AnyStep] Get steps ready to execute. .. py:property:: total_steps :type: int Total number of steps. .. py:class:: BaseStep(/, **data) Bases: :py:obj:`pydantic.BaseModel` Base class for all planning steps. This provides the core functionality that all step types share, while being flexible enough to support various planning patterns. 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. .. py:method:: add_dependency(step_id, dependency_type = DependencyType.HARD, condition = None, required_output = None) Add a dependency to this step. .. py:method:: is_ready(completed_steps) Check if all dependencies are satisfied. .. py:method:: mark_completed(output = None) Mark step as completed. .. py:method:: mark_failed(error) Mark step as failed. .. py:method:: mark_in_progress() Mark step as in progress. .. py:method:: mark_ready() Mark step as ready to execute. .. py:method:: to_prompt_format() Format step for inclusion in prompts. .. py:method:: validate_unique_dependencies(v) :classmethod: Ensure no duplicate dependencies. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: ConditionalStep(/, **data) Bases: :py:obj:`BaseStep` Step with conditional execution paths. 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. .. py:class:: DAGPlan(/, **data) Bases: :py:obj:`BasePlan` Plan with explicit DAG structure (LLM Compiler style). 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. .. py:method:: validate_dag() Validate that plan forms a valid DAG (no cycles). .. py:class:: Dependency(/, **data) Bases: :py:obj:`pydantic.BaseModel` Represents a dependency between steps. 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. .. py:method:: is_satisfied(step_results) Check if this dependency is satisfied. .. py:class:: DependencyType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Type of dependency between steps. Initialize self. See help(type(self)) for accurate signature. .. py:class:: ExecutionMode Bases: :py:obj:`str`, :py:obj:`enum.Enum` How a step should be executed. Initialize self. See help(type(self)) for accurate signature. .. py:class:: ParallelStep(/, **data) Bases: :py:obj:`BaseStep` Container for steps that can execute in parallel. 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. .. py:class:: RecursiveStep(/, **data) Bases: :py:obj:`BaseStep` Step that can spawn sub-plans recursively. 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. .. py:class:: ResearchStep(/, **data) Bases: :py:obj:`BaseStep` Step for information gathering and research. 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. .. py:class:: SequentialPlan(/, **data) Bases: :py:obj:`BasePlan` Traditional sequential 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. .. py:method:: add_sequential_step(step, depends_on_previous = True) Add step with automatic dependency on previous step. .. py:class:: StepMetadata(/, **data) Bases: :py:obj:`pydantic.BaseModel` Metadata for tracking step execution and debugging. 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. .. py:property:: execution_time :type: float | None Calculate execution time in seconds. .. py:class:: StepStatus Bases: :py:obj:`str`, :py:obj:`enum.Enum` Universal status for any plan step. Initialize self. See help(type(self)) for accurate signature. .. py:class:: StepType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Type of plan step - extensible for different planning patterns. Initialize self. See help(type(self)) for accurate signature.