Terraphim Agent Registry
Knowledge graph-based agent registry for intelligent agent discovery and capability matching in the Terraphim AI ecosystem.
Overview
The terraphim_agent_registry crate provides a sophisticated agent registry that leverages Terraphim's knowledge graph infrastructure to enable intelligent agent discovery, capability matching, and role-based specialization. It integrates seamlessly with the existing automata and role graph systems to provide context-aware agent management.
Key Features
- Knowledge Graph Integration: Uses existing
extract_paragraphs_from_automataandis_all_terms_connected_by_pathfor intelligent agent discovery - Role-Based Specialization: Leverages
terraphim_rolegraphfor agent role management and hierarchy - Capability Matching: Semantic matching of agent capabilities to task requirements
- Agent Metadata: Rich metadata storage with knowledge graph context
- Dynamic Discovery: Real-time agent discovery based on evolving requirements
- Performance Optimization: Efficient indexing and caching for fast lookups
- Multiple Discovery Algorithms: Exact match, fuzzy match, semantic match, and hybrid approaches
Architecture
┌─────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ Agent Registry │ │ Knowledge Graph │ │ Role Graph │
│ (Core) │◄──►│ Integration │◄──►│ Integration │
└─────────────────────┘ └──────────────────────┘ └─────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ Agent Metadata │ │ Discovery Engine │ │ Capability │
│ Management │ │ (Multiple Algos) │ │ Registry │
└─────────────────────┘ └──────────────────────┘ └─────────────────────┘
Core Concepts
Agent Roles
Every agent in the registry has a primary role and can have multiple secondary roles. Roles are integrated with the terraphim_rolegraph system:
use ;
let role = new;
// Roles support hierarchy and specialization
role.hierarchy_level = 2;
role.parent_roles = vec!;
role.child_roles = vec!;
role.knowledge_domains = vec!;
Agent Capabilities
Agents have well-defined capabilities with performance metrics and resource requirements:
use ;
let capability = AgentCapability ;
Knowledge Graph Context
Agents operate within knowledge graph contexts that define their understanding:
use KnowledgeContext;
let context = KnowledgeContext ;
Quick Start
1. Create a Registry
use Arc;
use ;
use RoleGraph;
async
2. Register Agents
use ;
// Create agent metadata
let agent_id = new;
let supervisor_id = new;
let primary_role = new;
let mut metadata = new;
// Add capabilities
let analysis_capability = AgentCapability ;
metadata.add_capability?;
// Register with registry
registry.register_agent.await?;
3. Discover Agents
use AgentDiscoveryQuery;
// Create discovery query
let query = AgentDiscoveryQuery ;
// Discover matching agents
let result = registry.discover_agents.await?;
println!;
for agent_match in result.matches
Discovery Algorithms
The registry supports multiple discovery algorithms:
Exact Match
use ;
let context = DiscoveryContext ;
Fuzzy Match
let context = DiscoveryContext ;
Semantic Match (Knowledge Graph)
let context = DiscoveryContext ;
Hybrid Approach
let context = DiscoveryContext ;
Knowledge Graph Integration
The registry integrates deeply with Terraphim's knowledge graph infrastructure:
Concept Extraction
// Uses extract_paragraphs_from_automata for intelligent context analysis
let task_description = "Plan a software development project using agile methodology";
let extracted_concepts = kg_integration.extract_concepts_from_text.await?;
// Returns: ["software", "development", "project", "agile", "methodology"]
Connectivity Analysis
// Uses is_all_terms_connected_by_path for requirement validation
let requirements = vec!;
let connectivity = kg_integration.analyze_term_connectivity.await?;
if connectivity.all_connected else
Role Hierarchy Navigation
// Leverages terraphim_rolegraph for role-based discovery
let related_roles = kg_integration.find_related_roles.await?;
// Returns parent roles, child roles, and sibling roles
Advanced Features
Capability Dependencies
let mut capability_registry = new;
// Register capabilities with dependencies
let advanced_planning = AgentCapability ;
capability_registry.register_capability?;
// Check if agent has all required dependencies
let agent_capabilities = vec!;
let can_use = capability_registry.check_dependencies;
Performance Monitoring
// Agents track performance metrics automatically
agent_metadata.record_task_completion;
agent_metadata.record_resource_usage;
let success_rate = agent_metadata.get_success_rate; // 0.0 to 1.0
Dynamic Role Assignment
// Agents can assume multiple roles
let secondary_role = new;
agent_metadata.add_secondary_role?;
// Check if agent can fulfill a role
if agent_metadata.has_role
Integration with Terraphim Ecosystem
With Agent Supervisor
use ;
// Registry integrates with supervision system
let supervisor = new;
// Agents found through registry can be supervised
for agent_match in discovery_result.matches
With Messaging System
use ;
// Discovered agents can communicate through messaging system
let message_system = new;
for agent_match in discovery_result.matches
With GenAgent Framework
use ;
// Registry works with GenAgent runtime system
let factory = new;
for agent_match in discovery_result.matches
Configuration
Registry Configuration
let config = RegistryConfig ;
Knowledge Graph Configuration
let automata_config = AutomataConfig ;
let similarity_thresholds = SimilarityThresholds ;
Performance
The registry is optimized for high performance:
- Efficient Indexing: Agents indexed by role, capability, and domain
- Caching: Query results cached with configurable TTL
- Background Processing: Automatic cleanup and monitoring
- Concurrent Access: Thread-safe operations with minimal locking
Benchmarks
Run benchmarks to see performance characteristics:
Testing
Run the comprehensive test suite:
# Unit tests
# Integration tests
# All tests with logging
RUST_LOG=debug
Examples
See the tests/ directory for comprehensive examples:
- Basic agent registration and discovery
- Knowledge graph integration
- Role-based specialization
- Capability matching
- Performance monitoring
- Multi-algorithm discovery
Contributing
Contributions are welcome! Please see the main Terraphim repository for contribution guidelines.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.