Skip to content

OSSS.ai.dependencies.execution_planner

OSSS.ai.dependencies.execution_planner

Execution planner for optimized agent execution strategies.

This module provides execution planning capabilities that work with the dependency graph engine to create optimal execution plans considering parallelism, resource constraints, and failure scenarios.

ExecutionStrategy

Bases: Enum

Execution strategy types.

StageType

Bases: Enum

Types of execution stages.

ParallelGroup

Bases: BaseModel

Group of agents that can execute in parallel.

Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.

can_add_agent(agent_id, node)

Check if an agent can be added to this parallel group.

ExecutionStage

Bases: BaseModel

A stage in the execution plan.

Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.

get_all_agents()

Get all agents in this stage.

get_execution_count()

Get total number of agents to execute in this stage.

is_parallel()

Check if this stage involves parallel execution.

ExecutionPlan

Bases: BaseModel

Complete execution plan with stages and metadata.

Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.

get_total_stages()

Get total number of stages in the plan.

get_current_stage()

Get the current execution stage.

advance_stage()

Advance to the next stage. Returns True if successful.

get_remaining_stages()

Get remaining stages to execute.

get_completion_percentage()

Get completion percentage (0-100).

is_completed()

Check if execution plan is completed.

get_execution_summary()

Get execution summary statistics.

ExecutionPlanBuilder

Bases: ABC

Abstract base for execution plan builders.

build_plan(graph_engine, context=None) abstractmethod

Build an execution plan from the dependency graph.

SequentialPlanBuilder

Bases: ExecutionPlanBuilder

Builder for sequential execution plans.

build_plan(graph_engine, context=None)

Build a sequential execution plan.

ParallelBatchedPlanBuilder

Bases: ExecutionPlanBuilder

Builder for parallel batched execution plans.

build_plan(graph_engine, context=None)

Build a parallel batched execution plan.

AdaptivePlanBuilder

Bases: ExecutionPlanBuilder

Builder for adaptive execution plans that adjust based on conditions.

build_plan(graph_engine, context=None)

Build an adaptive execution plan.

PriorityFirstPlanBuilder

Bases: ExecutionPlanBuilder

Builder for priority-first execution plans.

build_plan(graph_engine, context=None)

Build a priority-first execution plan that respects dependencies.

ExecutionPlanner

Main execution planner that coordinates different planning strategies.

Provides a unified interface for creating optimized execution plans based on dependency graphs, execution strategies, and runtime conditions.

create_plan(graph_engine, strategy=None, context=None, **kwargs)

Create an execution plan using the specified strategy.

Parameters

graph_engine : DependencyGraphEngine The dependency graph to plan execution for strategy : Optional[ExecutionStrategy] Execution strategy to use (defaults to adaptive) context : Optional[AgentContext] Current execution context **kwargs Additional parameters for specific builders

Returns

ExecutionPlan Optimized execution plan

compare_strategies(graph_engine, strategies=None, context=None)

Compare multiple execution strategies and return all plans.

Parameters

graph_engine : DependencyGraphEngine The dependency graph to plan for strategies : Optional[List[ExecutionStrategy]] List of strategies to compare (defaults to all available) context : Optional[AgentContext] Current execution context

Returns

Dict[ExecutionStrategy, ExecutionPlan] Mapping of strategies to their execution plans

recommend_strategy(graph_engine, context=None, optimization_goal='balanced')

Recommend the best execution strategy based on graph characteristics.

Parameters

graph_engine : DependencyGraphEngine The dependency graph to analyze context : Optional[AgentContext] Current execution context optimization_goal : str Optimization goal: "speed", "reliability", "resource", "balanced"

Returns

ExecutionStrategy Recommended execution strategy