-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcp_analysis.py
More file actions
108 lines (94 loc) · 3.43 KB
/
Copy pathfcp_analysis.py
File metadata and controls
108 lines (94 loc) · 3.43 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""Measure FCP token cost per agent (hot path + cold path) and report redundancy.
Reads from live profile SOUL.md files and fleet/PROTOCOL.md.
Uses absolute host paths because agent profile homes can make ``~`` ambiguous.
"""
from pathlib import Path
hermes_root = Path("/Users/deepg/.hermes")
profiles = hermes_root / "profiles"
fleet = hermes_root / "fleet"
agents = ["oracle", "arch", "eureka", "aurus"]
# Heading patterns to search for (in priority order)
HEADING_PATTERNS = [
"## FCP v2",
"### FCP v2",
"## FCP v3",
"### FCP v3",
"## Fleet Communication Protocol",
"### Fleet Communication Protocol",
]
results = {}
for agent in agents:
soul_path = profiles / agent / "SOUL.md"
if not soul_path.exists():
print(f" WARNING: {soul_path} not found, skipping {agent}")
continue
content = soul_path.read_text()
fcp_start = -1
for pattern in HEADING_PATTERNS:
idx = content.find(pattern)
if idx >= 0:
fcp_start = idx
break
if fcp_start < 0:
print(f" WARNING: no FCP heading found in {agent}/SOUL.md, skipping")
continue
rest = content[fcp_start:]
lines = rest.split("\n")
fcp_lines = []
for i, line in enumerate(lines):
if i > 0 and (line.startswith("---") or (line.startswith("## ") and "FCP" not in line.upper())):
break
fcp_lines.append(line)
fcp_content = "\n".join(fcp_lines)
non_empty = [l for l in fcp_lines if l.strip()]
results[agent] = {
"lines": len(non_empty),
"chars": len(fcp_content),
"tokens": len(fcp_content) // 4,
"total_chars": len(content),
"total_tokens": len(content) // 4,
}
protocol_path = fleet / "PROTOCOL.md"
if not protocol_path.exists():
print(f"WARNING: {protocol_path} not found")
pc = ""
else:
pc = protocol_path.read_text()
print("=== CURRENT FCP TOKEN COST ===")
print(f"PROTOCOL.md (cold path): {len(pc.splitlines())} lines, ~{len(pc)//4} tokens")
print()
if not results:
raise SystemExit("ERROR: No FCP sections found in any SOUL.md. Check heading patterns above.")
tot_t = 0
for a, d in results.items():
pct = d["chars"] * 100 // d["total_chars"]
print(f" {a} SOUL FCP: {d['lines']} lines, ~{d['tokens']} tokens ({pct}% of SOUL.md)")
tot_t += d["tokens"]
print(f"\n TOTAL hot-path: ~{tot_t} tokens/turn fleet-wide")
print(f" Per session (20 msgs x 4 agents): ~{20*4*tot_t:,} tokens FCP overhead")
# Redundancy
print("\n=== REDUNDANCY ===")
print(" Channel map: 5 copies")
print(" Anti-Loop Rule: 5 copies")
print(" Delegation steps: 5 copies")
print(" Specialist sections ~85% identical across agents")
# Specialist comparison
spec_content = {}
for agent in ["arch", "eureka", "aurus"]:
soul_path = profiles / agent / "SOUL.md"
if not soul_path.exists():
continue
c = soul_path.read_text()
for pattern in HEADING_PATTERNS:
fs = c.find(pattern)
if fs >= 0:
spec_content[agent] = set(c[fs:].split("\n")[:55])
break
if len(spec_content) >= 2:
agents_list = list(spec_content.keys())
for i in range(len(agents_list)):
for j in range(i+1, len(agents_list)):
a, b = agents_list[i], agents_list[j]
common = len(spec_content[a] & spec_content[b])
total = len(spec_content[a] | spec_content[b])
print(f" {a} vs {b}: {common}/{total} lines shared ({common*100//total}% identical)")