H.1.5: Component Discovery Service (Redis-Backed)
Enables agents and components to register themselves and be discovered by capability. Based on AUTONOMOUS-AGENT-SYSTEM-DESIGN.md specifications.
Features:
- Component/Agent registration with capabilities
- Capability-based discovery with load balancing
- Health monitoring with heartbeats
- TTL-based auto-cleanup for stale registrations
- Local fallback mode when Redis is unavailable
Usage: from scripts.core.discovery_service import DiscoveryService, Component, Capability
# Initialize (auto-detects Redis or falls back to local)
discovery = DiscoveryService()
# Register a component
component = Component(
id="agent/orchestrator",
name="orchestrator",
component_type="agent",
capabilities=[Capability(name="task_coordination", ...)],
...
)
await discovery.register(component)
# Find components by capability
components = await discovery.find_by_capability("task_coordination")
File: discovery_service.py
Classes
ComponentStatus
Component operational status
Capability
What a component can do
Component
Registered component (agent, skill, command, etc.)
DiscoveryResult
Result of a discovery query
DiscoveryBackend
Abstract backend for discovery service storage
LocalDiscoveryBackend
In-memory backend for local development or when Redis unavailable
RedisDiscoveryBackend
Redis-backed discovery service for production use
DiscoveryService
Main discovery service with automatic backend selection.
Functions
to_dict()
No description
from_dict(cls, data)
No description
to_dict()
Convert to dictionary for storage
from_dict(cls, data)
Create from dictionary
load_ratio()
Current load as ratio of max concurrency
Usage
python discovery_service.py