-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (38 loc) · 1.71 KB
/
Copy pathmain.py
File metadata and controls
52 lines (38 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Entry point for the autonomous self-correcting executor
# Integrates with UMDR MCP stack for full runtime capabilities
from agents.executor import execute_task
from agents.mutator import mutate_protocol
from utils.logger import log
from utils.tracker import get_protocol_stats
import sys
def run_self_correcting_executor(protocol="default_protocol", iterations=1):
"""Run the self-correcting executor with automatic mutation"""
log("🚀 Starting Self-Correcting MCP Executor")
log(f"Protocol: {protocol}, Iterations: {iterations}")
for i in range(iterations):
log(f"\n--- Iteration {i + 1}/{iterations} ---")
# Execute the protocol
outcome = execute_task(protocol)
# Immediate mutation check after each execution
mutated = mutate_protocol(protocol)
# Log iteration summary
stats = get_protocol_stats(protocol)
if stats:
log(
f"Current stats - Success rate: {stats['success_rate']:.2%}, "
f"Total executions: {stats['total_executions']}"
)
if mutated:
log(f"🔄 Protocol {protocol} was mutated due to poor performance")
log(f"✅ Self-correcting executor completed {iterations} iterations")
# Final analysis
final_stats = get_protocol_stats(protocol)
if final_stats:
log(f"Final performance - Success rate: {final_stats['success_rate']:.2%}")
return final_stats
if __name__ == "__main__":
# Command line arguments
protocol = sys.argv[1] if len(sys.argv) > 1 else "default_protocol"
iterations = int(sys.argv[2]) if len(sys.argv) > 2 else 5
# Run the self-correcting executor
run_self_correcting_executor(protocol, iterations)