forked from karpathy/llm-council
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify_tool_schema.py
More file actions
156 lines (130 loc) · 4.99 KB
/
verify_tool_schema.py
File metadata and controls
156 lines (130 loc) · 4.99 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env python3
"""
Verify the tool schema includes all CEO constraint requirements.
"""
import sys
import os
# Add mcp_server to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "mcp_server"))
# Mock MCP types to allow import
class Tool:
def __init__(self, name, description, inputSchema):
self.name = name
self.description = description
self.inputSchema = inputSchema
class TextContent:
pass
class Server:
def __init__(self, name):
self.name = name
def list_tools(self):
def decorator(func):
return func
return decorator
def call_tool(self):
def decorator(func):
return func
return decorator
def create_initialization_options(self):
return {}
class StdioServer:
pass
# Mock the mcp module
sys.modules['mcp'] = type(sys)('mcp')
sys.modules['mcp.server'] = type(sys)('mcp.server')
sys.modules['mcp.server.stdio'] = type(sys)('mcp.server.stdio')
sys.modules['mcp.types'] = type(sys)('mcp.types')
sys.modules['mcp'].server = sys.modules['mcp.server']
sys.modules['mcp.server'].Server = Server
sys.modules['mcp.server'].stdio = sys.modules['mcp.server.stdio']
sys.modules['mcp.server.stdio'].stdio_server = StdioServer
sys.modules['mcp'].types = sys.modules['mcp.types']
sys.modules['mcp.types'].Tool = Tool
sys.modules['mcp.types'].TextContent = TextContent
# Now import the actual server module
import mcp_server.mcp_server as server_module
# Get the list_tools function
import asyncio
async def verify_schema():
"""Verify the tool schema meets all requirements."""
print("Verifying LLM Council Tool Schema...\n")
tools = await server_module.list_tools()
# Find the deliberate tool
deliberate_tool = None
for tool in tools:
if tool.name == "llm_council_deliberate":
deliberate_tool = tool
break
if not deliberate_tool:
print("❌ ERROR: llm_council_deliberate tool not found")
return False
print("Tool Name:", deliberate_tool.name)
print("\n" + "=" * 70)
print("DESCRIPTION:")
print("=" * 70)
print(deliberate_tool.description)
print()
# Check requirements
requirements = {
"HIGH COST warning": "⚠️ HIGH COST" in deliberate_tool.description or "HIGH COST" in deliberate_tool.description,
"Complexity threshold": "complexity ≥70" in deliberate_tool.description or "≥70" in deliberate_tool.description,
"Good use cases": "Architecture decisions" in deliberate_tool.description,
"Bad use cases": "Bug fixes" in deliberate_tool.description or "NOT FOR" in deliberate_tool.description,
"Anti-pattern warning": "frequent" in deliberate_tool.description.lower() or "routine" in deliberate_tool.description.lower(),
}
print("=" * 70)
print("DESCRIPTION REQUIREMENTS:")
print("=" * 70)
for req, met in requirements.items():
status = "✓" if met else "❌"
print(f"{status} {req}")
print()
# Check schema fields
schema = deliberate_tool.inputSchema
properties = schema.get("properties", {})
required = schema.get("required", [])
print("=" * 70)
print("INPUT SCHEMA:")
print("=" * 70)
schema_requirements = {
"prompt field exists": "prompt" in properties,
"complexity_score field exists": "complexity_score" in properties,
"strategic_justification field exists": "strategic_justification" in properties,
"strategic_justification is required": "strategic_justification" in required,
}
for req, met in schema_requirements.items():
status = "✓" if met else "❌"
print(f"{status} {req}")
if "complexity_score" in properties:
cs = properties["complexity_score"]
print(f"\n complexity_score details:")
print(f" Type: {cs.get('type')}")
print(f" Min: {cs.get('minimum')}")
print(f" Max: {cs.get('maximum')}")
print(f" Description: {cs.get('description', '')[:80]}...")
if "strategic_justification" in properties:
sj = properties["strategic_justification"]
print(f"\n strategic_justification details:")
print(f" Type: {sj.get('type')}")
print(f" Description: {sj.get('description', '')[:80]}...")
print()
# Overall verification
all_passed = all(requirements.values()) and all(schema_requirements.values())
if all_passed:
print("=" * 70)
print("✅ ALL REQUIREMENTS MET")
print("=" * 70)
print("\nThe LLM Council MCP tool is now constrained for:")
print(" • Strategic decisions only (complexity ≥70)")
print(" • Requires justification")
print(" • Prominent cost warning")
print(" • Clear good/bad use case examples")
return True
else:
print("=" * 70)
print("❌ SOME REQUIREMENTS NOT MET")
print("=" * 70)
return False
if __name__ == "__main__":
success = asyncio.run(verify_schema())
sys.exit(0 if success else 1)