Skip to content

Structured multi-perspective deliberation for hard decisions. Run full councils, focused triads, or duo debates across Claude Code, Codex, Gemini CLI, and OpenCode.

feat: auto-detect providers and route council members across LLMs (#8)

nyk757e5c04cd3e
diff --git a/SKILL.md b/SKILL.md
index abd0098..83374cc 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -32,9 +32,11 @@ You are the Council Coordinator. Your job is to convene the right council member
| `--profile [name]` | Panel profile: `classic`, `exploration-orthogonal`, `execution-lean` |
| `--quick` | Fast 2-round mode (200-word analysis → 75-word position, no cross-examination) |
| `--duo` | 2-member dialectic using polarity pairs |
-| `--models [path]` | Provider/model slot mapping for multi-provider execution |
+| `--models [path]` | Manual provider/model slot mapping (overrides auto-routing) |
+| `--no-auto-route` | Disable auto-routing; use agent frontmatter defaults (Claude-only) |
+| `--dry-route` | Print the routing table without running the council |
-Flag priority: `--quick` / `--duo` set the mode. `--full` / `--triad` / `--members` / `--profile` set the panel. `--models` is additive.
+Flag priority: `--quick` / `--duo` set the mode. `--full` / `--triad` / `--members` / `--profile` set the panel. `--models` overrides auto-routing. `--no-auto-route` and `--dry-route` are additive.
---
@@ -171,20 +173,33 @@ Follow these steps in order. Do NOT skip steps or merge rounds.
`[CHECKPOINT]` State the selected members and mode before proceeding.
-### STEP 1: Model/Provider Routing (OPTIONAL)
+### STEP 1: Provider Detection and Model Routing
-If `--models [path]` is provided:
+**Path A — Manual routing** (`--models [path]` provided):
1. Load the YAML mapping
-2. Assign each member to their specified provider/model
+2. Assign each member to their specified provider/model per the mapping
3. Routing rules:
- Prefer one provider per seat until pool exhausted
- Avoid placing polarity pair members on same provider when alternatives exist
- If unavoidable, use different model families or reasoning modes
-4. Log routing metadata: member → provider → model → reasoning_mode
+4. Log routing metadata: member → provider → model
-If no `--models` flag → use default configured models from agent frontmatter.
+**Path B — Auto-routing** (default when no `--models` and no `--no-auto-route`):
+1. Run the detection script via Bash: `bash ~/.claude/skills/council/scripts/detect-providers.sh`
+2. Parse the JSON output. If `provider_count == 1` (only anthropic): skip routing entirely, use agent frontmatter defaults. Proceed to Step 1.5.
+3. If `provider_count >= 2`: apply the routing algorithm below.
+4. If `--dry-route`: print the routing table and stop (do not convene the council).
-`[CHECKPOINT]` If routing used, confirm member → provider mapping.
+**Auto-routing algorithm** (apply in order):
+1. **Polarity pair separation** (hard constraint): For any polarity pair where both members are on the panel, assign them to different providers. Check the `council.polarity_pairs` field in each member's frontmatter.
+2. **Provider spread** (hard constraint): Distribute members across available providers as evenly as possible. With N providers and M members, each provider gets floor(M/N) or ceil(M/N) members.
+3. **Provider affinity** (soft tiebreaker): Use the `council.provider_affinity` field in each member's frontmatter. When choosing which provider to assign a member to, prefer providers listed earlier in their affinity array.
+4. **Tier matching** (soft): Members with `model: opus` in frontmatter get high-tier models per `configs/auto-route-defaults.yaml`. Members with `model: sonnet` get mid-tier models.
+
+**Path C — No routing** (`--no-auto-route`):
+Use agent frontmatter `model` defaults (Claude-only). Skip detection entirely.
+
+`[CHECKPOINT]` State the routing table: member → provider → model → exec_method. If `--dry-route`, output the table and stop here.
### STEP 1.5: Problem Restate Gate
@@ -211,15 +226,46 @@ Do NOT begin your analysis yet. Just the restatement and alternative framing. 50
Emit to user:
> **Council convened**: {member names}. Beginning Round 1 — independent analysis.
-Spawn each selected council member as a subagent:
-- `subagent_type: "general-purpose"` (agents are in ~/.claude/agents/)
-- Run all members **IN PARALLEL**
-- Each member sees ONLY the problem statement (blind-first, no peer outputs)
+Run all members **IN PARALLEL**. Each member sees ONLY the problem statement (blind-first, no peer outputs).
-Prompt template for each member:
+**Dispatch by exec_method** (from routing table):
+
+**For `subagent` (Anthropic)** — spawn as Claude Code subagent:
+- Use `subagent_type` matching the council member's agent name (agents are in ~/.claude/agents/)
+- Use the `model` parameter from the routing table (opus/sonnet/haiku) to override the agent's default if needed
+
+**For `codex_exec` (OpenAI)** — run via Bash tool:
+1. Read the member's agent file at `~/.claude/agents/council-{name}.md`
+2. Extract the **Identity**, **Grounding Protocol**, and relevant **Output Format** sections (trimmed — skip Analytical Method, What You See/Miss, When Deliberating)
+3. Build the full prompt with identity inlined, then run:
+```bash
+codex exec -c model="{model}" -c auto_approve=true "{full prompt}" 2>/dev/null
+```
+4. Capture stdout as the member's output. Timeout: 60 seconds.
+
+**For `gemini_cli` (Google)** — run via Bash tool:
+1. Read and extract identity sections (same as codex_exec above)
+2. Run:
+```bash
+gemini -m {model} -p "{full prompt}" 2>/dev/null
+```
+3. Capture stdout. Timeout: 60 seconds.
+
+**For `ollama_run` (Ollama)** — run via Bash tool:
+1. Read and extract identity sections (same as above)
+2. Run:
+```bash
+ollama run {model} "{full prompt}" 2>/dev/null
+```
+3. Capture stdout. Timeout: 120 seconds (local models are slower).
+
+**Fallback**: If any external provider call fails or times out, log `[FALLBACK] {member} failed on {provider}/{model}. Falling back to anthropic/{frontmatter_model}.` and re-run as a Claude subagent. Skip the failed provider for remaining rounds.
+
+**Prompt template** (used for ALL providers — for external providers, inline the identity preamble):
```
You are operating as a council member in a structured deliberation.
-Read your agent definition at ~/.claude/agents/council-{name}.md and follow it precisely.
+{For subagent: "Read your agent definition at ~/.claude/agents/council-{name}.md and follow it precisely."}
+{For external providers: paste the extracted Identity + Grounding Protocol + Output Format sections here}
The problem under deliberation:
{problem}
@@ -232,6 +278,8 @@ Do NOT try to anticipate what other members will say.
Limit: 400 words maximum.
```
+**Note**: The same dispatch logic applies to all subsequent rounds (Steps 3 and 5). Use the routing table from Step 1 consistently. If a provider failed and fell back in an earlier round, use the fallback provider for all remaining rounds.
+
`[CHECKPOINT]` Confirm all Round 1 outputs collected. Verify each is ≤400 words and follows the member's Output Format.
### STEP 3: Round 2 — Cross-Examination
@@ -446,7 +494,10 @@ Use the Duo Verdict template below.
### Council Composition
{Members convened, mode used, and selection rationale}
-{If model routing used: member → provider/model map. Otherwise omit.}
+
+### Provider Routing
+{Routing table: member → provider → model. Note any fallbacks triggered. If single-provider (Claude-only): "Default models (single provider)."}
+
### Unresolved Questions
{Questions the council could not answer — inputs needed from user. Lead with what the council does NOT know.}
@@ -469,6 +520,7 @@ Use the Duo Verdict template below.
### Epistemic Diversity Scorecard
- Perspective spread (1-5): {how orthogonal the viewpoints were}
+- Provider spread (1-5): {how distributed across model families — 1 if single provider}
- Evidence mix: {% empirical / mechanistic / strategic / ethical / heuristic}
- Convergence risk: {Low/Medium/High with reason}
diff --git a/agents/council-ada.md b/agents/council-ada.md
index f3ce1f8..aef5673 100644
--- a/agents/council-ada.md
+++ b/agents/council-ada.md
@@ -12,6 +12,7 @@ council:
triads: ["architecture", "debugging", "innovation", "complexity", "ai"]
duo_keywords: ["formalization", "systems", "abstraction"]
profiles: ["classic", "exploration-orthogonal", "execution-lean"]
+ provider_affinity: ["openai", "anthropic"]
---
## Identity
diff --git a/agents/council-aristotle.md b/agents/council-aristotle.md
index d54766f..b23f056 100644
--- a/agents/council-aristotle.md
+++ b/agents/council-aristotle.md
@@ -12,6 +12,7 @@ council:
triads: ["architecture", "innovation", "complexity", "systems"]
duo_keywords: ["architecture", "structure", "categories"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["anthropic", "openai", "google"]
---
## Identity
diff --git a/agents/council-aurelius.md b/agents/council-aurelius.md
index 78430f3..4b2033b 100644
--- a/agents/council-aurelius.md
+++ b/agents/council-aurelius.md
@@ -12,6 +12,7 @@ council:
triads: ["strategy", "ethics", "conflict", "risk", "decision"]
duo_keywords: ["strategy", "competition", "market"]
profiles: ["classic", "exploration-orthogonal", "execution-lean"]
+ provider_affinity: ["anthropic"]
---
## Identity
diff --git a/agents/council-feynman.md b/agents/council-feynman.md
index 0f7cde7..030a7e4 100644
--- a/agents/council-feynman.md
+++ b/agents/council-feynman.md
@@ -12,6 +12,7 @@ council:
triads: ["architecture", "debugging", "risk", "shipping"]
duo_keywords: ["decision", "bias", "thinking", "judgment"]
profiles: ["classic", "exploration-orthogonal", "execution-lean"]
+ provider_affinity: ["openai", "anthropic"]
---
## Identity
diff --git a/agents/council-kahneman.md b/agents/council-kahneman.md
index 804f329..1c8b299 100644
--- a/agents/council-kahneman.md
+++ b/agents/council-kahneman.md
@@ -12,6 +12,7 @@ council:
triads: ["decision", "bias"]
duo_keywords: ["decision", "bias", "thinking", "judgment"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["anthropic"]
---
## Identity
diff --git a/agents/council-karpathy.md b/agents/council-karpathy.md
index faea05e..2deefeb 100644
--- a/agents/council-karpathy.md
+++ b/agents/council-karpathy.md
@@ -12,6 +12,7 @@ council:
triads: ["ai", "ai-product"]
duo_keywords: ["ai", "ml", "neural", "model", "training"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["openai", "anthropic"]
---
## Identity
diff --git a/agents/council-lao-tzu.md b/agents/council-lao-tzu.md
index bc5aba3..7dc64a0 100644
--- a/agents/council-lao-tzu.md
+++ b/agents/council-lao-tzu.md
@@ -12,6 +12,7 @@ council:
triads: ["ethics", "innovation", "complexity", "systems"]
duo_keywords: ["architecture", "structure", "categories"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["anthropic"]
---
## Identity
diff --git a/agents/council-machiavelli.md b/agents/council-machiavelli.md
index fd8c715..dcb2280 100644
--- a/agents/council-machiavelli.md
+++ b/agents/council-machiavelli.md
@@ -12,6 +12,7 @@ council:
triads: ["strategy", "conflict", "product", "ai-product", "economics"]
duo_keywords: ["formalization", "systems", "abstraction"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["anthropic", "google"]
---
## Identity
diff --git a/agents/council-meadows.md b/agents/council-meadows.md
index 18d523a..0c3727f 100644
--- a/agents/council-meadows.md
+++ b/agents/council-meadows.md
@@ -12,6 +12,7 @@ council:
triads: ["systems"]
duo_keywords: ["systems", "feedback", "complexity", "loops"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["anthropic", "google"]
---
## Identity
diff --git a/agents/council-munger.md b/agents/council-munger.md
index 82d20e6..ed3222b 100644
--- a/agents/council-munger.md
+++ b/agents/council-munger.md
@@ -12,6 +12,7 @@ council:
triads: ["decision", "economics"]
duo_keywords: ["economics", "investment", "models", "moat"]
profiles: ["classic"]
+ provider_affinity: ["anthropic", "google"]
---
## Identity
diff --git a/agents/council-musashi.md b/agents/council-musashi.md
index 2b43d2c..6e2ea25 100644
--- a/agents/council-musashi.md
+++ b/agents/council-musashi.md
@@ -12,6 +12,7 @@ council:
triads: ["shipping", "founder"]
duo_keywords: ["shipping", "execution", "release"]
profiles: ["classic"]
+ provider_affinity: ["anthropic", "openai", "google"]
---
## Identity
diff --git a/agents/council-rams.md b/agents/council-rams.md
index 1540a55..1616947 100644
--- a/agents/council-rams.md
+++ b/agents/council-rams.md
@@ -12,6 +12,7 @@ council:
triads: ["design"]
duo_keywords: ["design", "user", "usability", "ux"]
profiles: ["classic"]
+ provider_affinity: ["openai", "anthropic"]
---
## Identity
diff --git a/agents/council-socrates.md b/agents/council-socrates.md
index 9584aed..91f541b 100644
--- a/agents/council-socrates.md
+++ b/agents/council-socrates.md
@@ -12,6 +12,7 @@ council:
triads: ["ethics", "debugging", "conflict", "ai-safety", "bias"]
duo_keywords: ["framing", "purpose", "meaning"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["anthropic"]
---
## Identity
diff --git a/agents/council-sun-tzu.md b/agents/council-sun-tzu.md
index b7312e6..5f667eb 100644
--- a/agents/council-sun-tzu.md
+++ b/agents/council-sun-tzu.md
@@ -12,6 +12,7 @@ council:
triads: ["strategy", "risk", "founder", "uncertainty", "economics"]
duo_keywords: ["strategy", "competition", "market"]
profiles: ["classic", "exploration-orthogonal", "execution-lean"]
+ provider_affinity: ["anthropic", "google"]
---
## Identity
diff --git a/agents/council-sutskever.md b/agents/council-sutskever.md
index d8f0e07..d411079 100644
--- a/agents/council-sutskever.md
+++ b/agents/council-sutskever.md
@@ -12,6 +12,7 @@ council:
triads: ["ai", "ai-safety", "uncertainty"]
duo_keywords: ["ai-safety", "alignment", "risk"]
profiles: ["classic", "exploration-orthogonal"]
+ provider_affinity: ["anthropic", "openai", "google"]
---
## Identity
diff --git a/agents/council-taleb.md b/agents/council-taleb.md
index 99b83ec..6b0d8f7 100644
--- a/agents/council-taleb.md
+++ b/agents/council-taleb.md
@@ -12,6 +12,7 @@ council:
triads: ["uncertainty"]
duo_keywords: ["risk", "uncertainty", "fragility", "tail"]
profiles: ["classic"]
+ provider_affinity: ["anthropic", "openai", "google"]
---
## Identity
diff --git a/agents/council-torvalds.md b/agents/council-torvalds.md
index f723a9c..5773d95 100644
--- a/agents/council-torvalds.md
+++ b/agents/council-torvalds.md
@@ -12,6 +12,7 @@ council:
triads: ["shipping", "product", "founder", "ai-product", "design"]
duo_keywords: ["shipping", "execution", "release", "engineering", "theory", "pragmatism"]
profiles: ["classic", "exploration-orthogonal", "execution-lean"]
+ provider_affinity: ["openai", "anthropic"]
---
## Identity
diff --git a/agents/council-watts.md b/agents/council-watts.md
index f5b20fa..fc665c1 100644
--- a/agents/council-watts.md
+++ b/agents/council-watts.md
@@ -12,6 +12,7 @@ council:
triads: ["product", "design", "bias"]
duo_keywords: ["framing", "purpose", "meaning", "engineering", "theory", "pragmatism"]
profiles: ["classic"]
+ provider_affinity: ["anthropic"]
---
## Identity
diff --git a/configs/auto-route-defaults.yaml b/configs/auto-route-defaults.yaml
new file mode 100644
index 0000000..356a004
--- /dev/null
+++ b/configs/auto-route-defaults.yaml
@@ -0,0 +1,18 @@
+# Default model tier mapping per provider.
+# Used by the coordinator when auto-routing members to providers.
+# "high" = members with model: opus in frontmatter (heavyweight analysis)
+# "mid" = members with model: sonnet in frontmatter (faster/practical)
+
+provider_models:
+ anthropic:
+ high: opus
+ mid: sonnet
+ openai:
+ high: o3
+ mid: o4-mini
+ google:
+ high: gemini-2.5-pro
+ mid: gemini-2.5-pro
+ ollama:
+ high: null # uses first available model from detect-providers.sh
+ mid: null
diff --git a/install.sh b/install.sh
index 8814bcf..4d08eaa 100755
--- a/install.sh
+++ b/install.sh
@@ -100,6 +100,18 @@ done
echo "Installing council skill..."
run_cmd install -m 0644 "${SCRIPT_DIR}/SKILL.md" "${SKILL_DEST}"
+echo "Installing council scripts..."
+SCRIPTS_DEST_DIR="${SKILL_DEST_DIR}/scripts"
+run_cmd mkdir -p "${SCRIPTS_DEST_DIR}"
+scripts_installed=0
+shopt -s nullglob
+script_files=("${SCRIPT_DIR}"/scripts/detect-*.sh)
+shopt -u nullglob
+for script_file in "${script_files[@]}"; do
+ run_cmd install -m 0755 "${script_file}" "${SCRIPTS_DEST_DIR}/"
+ ((scripts_installed+=1))
+done
+
configs_installed=0
if [[ "$COPY_CONFIGS" == true ]]; then
if [[ -d "${CONFIGS_SRC_DIR}" ]]; then
@@ -122,6 +134,7 @@ echo
echo "Done."
echo " Installed ${installed_count} council agents to ${AGENTS_DEST}"
echo " Installed skill to ${SKILL_DEST}"
+echo " Installed ${scripts_installed} scripts to ${SCRIPTS_DEST_DIR}"
if [[ "$COPY_CONFIGS" == true ]]; then
echo " Installed ${configs_installed} config files to ${CONFIGS_DEST_DIR}"
fi
diff --git a/scripts/council-simulation-checklist.sh b/scripts/council-simulation-checklist.sh
index b7df74c..73a716d 100755
--- a/scripts/council-simulation-checklist.sh
+++ b/scripts/council-simulation-checklist.sh
@@ -114,6 +114,43 @@ if grep -q "^{" demos/verdict-template.md 2>/dev/null; then
fi
pass "Verdict template dedup check done"
+# --- Auto-routing checks ---
+
+[[ -f "scripts/detect-providers.sh" ]] || fail "scripts/detect-providers.sh is missing"
+[[ -x "scripts/detect-providers.sh" ]] || fail "scripts/detect-providers.sh is not executable"
+pass "detect-providers.sh exists and is executable"
+
+if detect_output="$(bash scripts/detect-providers.sh 2>/dev/null)"; then
+ if echo "$detect_output" | grep -q '"provider_count"'; then
+ pass "detect-providers.sh produces valid JSON"
+ else
+ fail "detect-providers.sh output missing provider_count field"
+ fi
+else
+ fail "detect-providers.sh exited with error"
+fi
+
+[[ -f "configs/auto-route-defaults.yaml" ]] || fail "configs/auto-route-defaults.yaml is missing"
+pass "Auto-route defaults config exists"
+
+grep -q -- "--no-auto-route" SKILL.md || fail "--no-auto-route flag missing in SKILL.md"
+pass "--no-auto-route flag documented in SKILL.md"
+
+grep -q -- "--dry-route" SKILL.md || fail "--dry-route flag missing in SKILL.md"
+pass "--dry-route flag documented in SKILL.md"
+
+affinity_count=0
+for agent_file in agents/council-*.md; do
+ if grep -q "provider_affinity" "$agent_file" 2>/dev/null; then
+ ((affinity_count+=1))
+ fi
+done
+if [[ "$affinity_count" -eq "$agent_count" ]]; then
+ pass "All agents have provider_affinity in frontmatter"
+else
+ warn "Only ${affinity_count}/${agent_count} agents have provider_affinity"
+fi
+
# --- Install script checks ---
if command -v shellcheck >/dev/null 2>&1; then
diff --git a/scripts/detect-providers.sh b/scripts/detect-providers.sh
new file mode 100755
index 0000000..6864695
--- /dev/null
+++ b/scripts/detect-providers.sh
@@ -0,0 +1,103 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Council of High Intelligence — Provider Detection Script
+# Detects available LLM providers and outputs structured JSON to stdout.
+# Usage: ./scripts/detect-providers.sh
+
+TIMEOUT_SECONDS=5
+
+# --- Helper functions ---
+
+json_provider() {
+ local name="$1" available="$2" exec_method="$3" binary="$4" models="$5"
+ printf '{"name":"%s","available":%s,"exec_method":"%s","binary":"%s","models":[%s]}' \
+ "$name" "$available" "$exec_method" "$binary" "$models"
+}
+
+check_command() {
+ command -v "$1" 2>/dev/null || echo ""
+}
+
+# macOS-compatible timeout using perl (no coreutils required)
+run_with_timeout() {
+ perl -e '
+ use POSIX ":sys_wait_h";
+ my $timeout = shift @ARGV;
+ my $pid = fork();
+ if ($pid == 0) { exec @ARGV; exit 1; }
+ my $elapsed = 0;
+ while ($elapsed < $timeout) {
+ if (waitpid($pid, WNOHANG) > 0) { exit ($? >> 8); }
+ select(undef, undef, undef, 0.1);
+ $elapsed += 0.1;
+ }
+ kill("TERM", $pid);
+ waitpid($pid, 0);
+ exit 124;
+ ' "$TIMEOUT_SECONDS" "$@" 2>/dev/null
+}
+
+# --- Detect each provider ---
+
+providers=()
+
+# Anthropic — always available (host runtime)
+providers+=("$(json_provider "anthropic" "true" "subagent" "native" '"opus","sonnet","haiku"')")
+
+# OpenAI via Codex CLI
+codex_bin="$(check_command codex)"
+if [[ -n "$codex_bin" ]] && run_with_timeout codex --version >/dev/null 2>&1; then
+ providers+=("$(json_provider "openai" "true" "codex_exec" "$codex_bin" '"o3","o4-mini"')")
+else
+ providers+=("$(json_provider "openai" "false" "codex_exec" "${codex_bin:-not_found}" '')")
+fi
+
+# Google via Gemini CLI
+gemini_bin="$(check_command gemini)"
+if [[ -n "$gemini_bin" ]] && run_with_timeout gemini --version >/dev/null 2>&1; then
+ providers+=("$(json_provider "google" "true" "gemini_cli" "$gemini_bin" '"gemini-2.5-pro"')")
+else
+ providers+=("$(json_provider "google" "false" "gemini_cli" "${gemini_bin:-not_found}" '')")
+fi
+
+# Ollama (local models)
+ollama_bin="$(check_command ollama)"
+ollama_available=false
+ollama_models=""
+if [[ -n "$ollama_bin" ]]; then
+ # Check if ollama server is running by listing models
+ if model_list="$(run_with_timeout ollama list 2>/dev/null)"; then
+ ollama_available=true
+ # Parse model names from 'ollama list' output (skip header line, take first column)
+ ollama_models="$(echo "$model_list" | tail -n +2 | awk '{print $1}' | head -5 | \
+ sed 's/.*/"&"/' | paste -sd ',' -)"
+ fi
+fi
+providers+=("$(json_provider "ollama" "$ollama_available" "ollama_run" "${ollama_bin:-not_found}" "$ollama_models")")
+
+# --- Build JSON output ---
+
+available_count=0
+for p in "${providers[@]}"; do
+ if echo "$p" | grep -q '"available":true'; then
+ ((available_count+=1))
+ fi
+done
+
+multi_provider=false
+if [[ "$available_count" -ge 2 ]]; then
+ multi_provider=true
+fi
+
+# Assemble providers array
+provider_json=""
+for i in "${!providers[@]}"; do
+ if [[ $i -gt 0 ]]; then
+ provider_json+=","
+ fi
+ provider_json+="${providers[$i]}"
+done
+
+printf '{"providers":[%s],"provider_count":%d,"multi_provider":%s}\n' \
+ "$provider_json" "$available_count" "$multi_provider"