| name | king-skill |
| description | MASTER ROUTER — activates FIRST on every non-trivial task. Analyzes the problem, determines if a specialized tool/skill can resolve it without spending reasoning tokens, and orchestrates execution. Also enforces token-compression on ALL output. Trigger: ANY task involving computation, simulation, literature, verification, data, graphs, code, documents, or scientific analysis. No exceptions. The LLM is the orchestrator, not the executor.
|
| priority | 0 |
| version | 2 |
| integrates | token-compression (always active) |
King-Skill — Master Cognitive Orchestrator
Core principle
paradigm = {
"old": "task → LLM reasons → output # tokens ∝ complexity",
"new": "task → LLM routes → tool → LLM synth # tokens ∝ novelty only",
}
ALWAYS ACTIVE: token-compression
Dispatch algorithm
def king_dispatch(task: Task) -> Response:
category = classify(task)
skill = DISPATCH_TABLE.get(category)
if skill is None:
return reason_compressed(task)
try:
result = execute_skill(skill, task)
return synthesize_compressed(result, task.context)
except ToolError as e:
return fallback(task, e)
def should_delegate(task) -> bool:
return (
task.is_deterministic() and
task.has_known_tool() and
not task.needs_judgment()
)
Dispatch table
DISPATCH_TABLE = {
"numerical": "skill-01-python-executor",
"symbolic_algebra": "skill-09-sympy",
"sat_constraint": "skill-02-sat-solver",
"parallel_search": "skill-18-parallel-search",
"physics_ode": "skill-07-scipy-sim",
"fluid_dynamics": "skill-07-scipy-sim",
"signal_processing": "skill-01-python-executor",
"lean4_proof": "skill-05-lean4-verify",
"benchmark_check": "skill-17-benchmark-verifier",
"arxiv": "skill-03-arxiv-fetch",
"sequences": "skill-04-oeis-lookup",
"math_query": "skill-13-wolfram-query",
"physical_constants":"skill-04-oeis-lookup",
"graph_analysis": "skill-08-networkx",
"p2p_topology": "skill-08-networkx",
"doc_convert": "skill-06-doc-transform",
"latex_render": "skill-11-latex-renderer",
"code_translate": "skill-10-code-translator",
"git_ops": "skill-14-git-operations",
"etl_data": "skill-12-data-pipeline",
"cache_lookup": "skill-19-knowledge-cache",
"p2pclaw_api": "skill-15-p2pclaw-lab",
"paper_generate": "skill-20-report-generator",
"output_format": "token-compression",
}
Error & fallback protocol
skill.execute() → error
│
├─ ImportError/NotFound → bash: pip install {dep} → retry
├─ TimeoutError → reduce scope → retry with smaller params
├─ WrongResult → cross-verify with second tool
├─ NetworkError → use cached version if ∃ → else reason
└─ UnknownError → reason_compressed() + log for skill improvement
Decision flowchart
INPUT TASK
│
▼
[token-compression ALWAYS ON for output]
│
▼
is_deterministic ∧ has_tool?
│
YES │ NO
│ │
▼ ▼
check cache needs external data?
│ │
HIT │ MISS YES │ NO
│ │ │ │
▼ ▼ ▼ ▼
return execute fetch API reason with
cached skill → → synthesize token-compression
result cache result
Skill registry summary
| # | Skill ID | Domain | Token savings | P2PCLAW critical |
|---|
| 01 | python-executor | Numerical compute | ★★★★★ | ✓ |
| 02 | sat-solver | SAT/CSP/coloring | ★★★★★ | ✓ urgent |
| 03 | arxiv-fetch | Literature | ★★★★☆ | ✓ |
| 04 | oeis-nist | Sequences/constants | ★★★☆☆ | ✓ |
| 05 | lean4-verify | Formal proofs | ★★★★☆ | ✓ |
| 06 | doc-transform | Pandoc/PDF/DOCX | ★★★★★ | △ |
| 07 | scipy-sim | Physics simulation | ★★★★★ | △ |
| 08 | networkx | Graph analysis | ★★★★★ | ✓ |
| 09 | sympy | Symbolic algebra | ★★★★☆ | ✓ |
| 10 | code-translator | Lang conversion | ★★★☆☆ | △ |
| 11 | latex-renderer | Formal docs | ★★★☆☆ | ✓ |
| 12 | data-pipeline | ETL/pandas | ★★★★☆ | △ |
| 13 | wolfram-query | Advanced math | ★★★★☆ | ✓ |
| 14 | git-operations | Version control | ★★★☆☆ | △ |
| 15 | p2pclaw-lab | OpenCLAW API | ★★★★★ | ✓ |
| 16 | token-compression | Output optimizer | ∞ | ✓ installed |
| 17 | benchmark-verifier | Auto verification | ★★★★☆ | ✓ |
| 18 | parallel-search | Parallel compute | ★★★★★ | ✓ urgent |
| 19 | knowledge-cache | Result caching | ★★★★☆ | ✓ |
| 20 | report-generator | Paper generation | ★★★☆☆ | ✓ |
Success metrics
metrics = {
"token_reduction": "> 60% vs no-skill baseline",
"reasoning_quality": "≥ baseline (zero degradation)",
"delegation_rate": "> 80% of deterministic tasks",
"tool_success_rate": "> 95% (with fallback)",
"cache_hit_rate": "> 40% in long sessions",
}
Corrected dispatch order (order matters — specific before general)
DISPATCH_ORDER = [
"skill-15-p2pclaw-lab",
"skill-20-report-generator",
"skill-11-latex-renderer",
"skill-09-sympy",
"skill-01-python-executor",
"skill-02-sat-solver",
"skill-03-arxiv-fetch",
"skill-04-oeis-nist",
"skill-05-lean4-verify",
"skill-06-doc-transform",
"skill-07-scipy-sim",
"skill-08-networkx",
"skill-10-code-translator",
"skill-12-data-pipeline",
"skill-13-wolfram-query",
"skill-14-git-operations",
"skill-18-parallel-search",
"skill-19-knowledge-cache",
"token_compression + direct_reasoning",
]