OSSS.ai.dependencies.dynamic_composition¶
OSSS.ai.dependencies.dynamic_composition
¶
Dynamic agent composition with runtime discovery and hot-swapping.
This module provides capabilities for discovering, loading, and dynamically composing agents at runtime, including hot-swapping of failed agents and dynamic graph reconfiguration.
DiscoveryStrategy
¶
Bases: Enum
Strategies for discovering agents.
CompositionEvent
¶
Bases: Enum
Events in the dynamic composition lifecycle.
DiscoveredAgentInfo
¶
CompositionRule
¶
Bases: BaseModel
Rule for dynamic composition decisions.
Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.
AgentDiscoverer
¶
FilesystemDiscoverer
¶
Bases: AgentDiscoverer
Discover agents by scanning the filesystem.
RegistryDiscoverer
¶
Bases: AgentDiscoverer
Discover agents using the agent registry.
DynamicAgentComposer
¶
Dynamic agent composer with runtime discovery and hot-swapping.
Provides capabilities for discovering agents at runtime, dynamically composing execution graphs, and hot-swapping failed or outdated agents.
add_discoverer(discoverer)
¶
Add an agent discoverer.
add_composition_rule(rule)
¶
Add a dynamic composition rule.
add_event_handler(event, handler)
¶
Add an event handler for composition events.
discover_agents(force_rediscovery=False)
async
¶
Run discovery across all configured discoverers.
load_agent(agent_id, force_reload=False)
async
¶
Load an agent by ID.
hot_swap_agent(old_agent_id, new_agent_id, context)
async
¶
Hot-swap one agent for another.
auto_discover_and_swap(context)
async
¶
Automatically discover new agents and perform beneficial swaps.
optimize_composition(context)
async
¶
Optimize the current agent composition using composition rules.
get_composition_status()
¶
Get comprehensive composition status.
enable_auto_discovery(interval_seconds=300)
¶
Enable automatic agent discovery.
enable_auto_swap()
¶
Enable automatic agent swapping.
create_version_upgrade_rule()
¶
Create a rule that swaps agents when newer versions are available.
create_failure_recovery_rule()
¶
Create a rule that swaps failing agents.