Skip to content

OSSS.ai.routing.resource_optimizer

OSSS.ai.routing.resource_optimizer

Resource Optimizer for Intelligent Agent Selection.

This module provides sophisticated resource optimization capabilities for agent selection, considering performance, cost, and resource constraints.

OptimizationStrategy

Bases: Enum

Optimization strategies for agent selection.

ResourceConstraints

Bases: BaseModel

Resource constraints for optimization decisions.

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

validate_agent_sets(v) classmethod

Validate that agent names are non-empty strings.

validate_constraint_consistency()

Validate that constraints are internally consistent.

is_agent_allowed(agent, strict_required=True)

Check if an agent is allowed by constraints.

Parameters:

Name Type Description Default
agent str

The agent name to check

required
strict_required bool

If True, check if required agents are present before allowing others. If False, allow any agent that's not forbidden.

True

validate_agent_count(count)

Validate agent count against constraints.

to_dict()

Convert to dictionary for serialization.

Maintained for backward compatibility. Uses Pydantic's model_dump() internally for consistent serialization.

ResourceOptimizer

Advanced resource optimizer for intelligent agent selection.

This optimizer considers multiple factors including performance metrics, resource constraints, cost optimization, and quality requirements to make optimal agent selection decisions.

__init__()

Initialize the resource optimizer.

select_optimal_agents(available_agents, complexity_score, performance_data, constraints=None, strategy=OptimizationStrategy.BALANCED, context_requirements=None)

Select optimal agents based on multiple optimization criteria.