diff --git a/README.md b/README.md index 156b31f..cdb99b2 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,15 @@ OLLIE_MEMORY_PATH=~/.config/ollie/memory # directory for memory files (ollie/m) OLLIE_ELEVATE_SOCKET=${XDG_RUNTIME_DIR}/ollie/elevate.sock # socket path for x/elevate adapter (default: $XDG_RUNTIME_DIR/ollie/elevate.sock) OLLIE_COMPLETE_BACKEND=ollama # backend for u/complete (required) OLLIE_COMPLETE_MODEL=qwen3:latest # model for u/complete (required) +OLLIE_ENABLED_BACKENDS=openrouter,anthropic # backends available for routing (comma-separated) + +# Per-backend tier models for t/route +OLLIE_TIER_WORKER_openrouter=mistralai/devstral-small +OLLIE_TIER_EXPERT_openrouter=anthropic/claude-sonnet-4-20250514 +OLLIE_TIER_WORKER_anthropic=claude-haiku-4-20250514 +OLLIE_TIER_EXPERT_anthropic=claude-sonnet-4-20250514 +OLLIE_TIER_WORKER_ollama=qwen3:8b +OLLIE_TIER_EXPERT_ollama=qwen3:32b ``` Shell environment variables take precedence over the env file. diff --git a/prompts/tools-route.md b/prompts/tools-route.md index 3d8c802..27a21b1 100644 --- a/prompts/tools-route.md +++ b/prompts/tools-route.md @@ -6,11 +6,14 @@ Route a subtask to an appropriate model tier. Fire-and-forget: returns immediate - `worker` (default) — scoped tasks: implement a function, apply an edit, investigate a file, extract information. - `expert` — tasks requiring deep reasoning, architectural judgment, or multi-file analysis with ambiguity. +Available backends for routing are listed in `$OLLIE_ENABLED_BACKENDS` (comma-separated). + **Calling convention**: ``` call_tool: calls=[{tool: "route", args: [""]}] call_tool: calls=[{tool: "route", args: ["", "--tier=worker"]}] call_tool: calls=[{tool: "route", args: ["", "--tier=expert"]}] +call_tool: calls=[{tool: "route", args: ["", "--tier=expert", "--backend=anthropic"]}] ``` Parallel fan-out: @@ -35,3 +38,4 @@ SUMMARY: - Never wait for results. Continue work or end your turn. - One task per call. - Default to `worker`. Use `expert` only when the task genuinely needs stronger reasoning. +- `--backend` overrides the default (parent's backend). Use when a specific backend is better suited. diff --git a/tools/route b/tools/route index 207208c..94666b9 100755 --- a/tools/route +++ b/tools/route @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ollie:parallel read # description: Route a subtask to an appropriate model tier. Returns immediately; the agent reports back to your prompt when done. -# Args: [--tier=worker|expert] [id] +# Args: [--tier=worker|expert] [--backend=] [id] set -euo pipefail OLLIE="${OLLIE:-$HOME/mnt/ollie}" @@ -12,11 +12,13 @@ die() { printf 'route: %s\n' "$*" >&2; exit 1; } # Parse args tier="worker" +backend_override="" instruction="" id="" for arg in "$@"; do case "$arg" in --tier=*) tier="${arg#--tier=}" ;; + --backend=*) backend_override="${arg#--backend=}" ;; *) [ -z "$instruction" ] && instruction="$arg" || id="$arg" ;; esac done @@ -24,19 +26,37 @@ done [ -z "$instruction" ] && die "instruction required" case "$tier" in - worker) - BACKEND="${OLLIE_CASCADE_BACKEND:-openrouter}" - MODEL="${OLLIE_CASCADE_MODEL:-mistralai/devstral-small}" - agent="worker" - ;; - expert) - BACKEND="${OLLIE_ESCALATE_BACKEND:-openrouter}" - MODEL="${OLLIE_ESCALATE_MODEL:-anthropic/claude-sonnet-4-20250514}" - agent="expert" - ;; + worker|expert) ;; *) die "unknown tier: $tier (use worker or expert)" ;; esac +# Resolve backend: explicit flag > parent session's backend > OLLIE_BACKEND +if [ -n "$backend_override" ]; then + BACKEND="$backend_override" +else + BACKEND=$(cat "$OLLIE/s/$OLLIE_SESSION_ID/backend" 2>/dev/null || echo "${OLLIE_BACKEND:-openrouter}") +fi + +# Resolve model: OLLIE_TIER_{TIER}_{BACKEND} > legacy flat vars > hardcoded defaults +tier_upper=$(echo "$tier" | tr '[:lower:]' '[:upper:]') +backend_lower=$(echo "$BACKEND" | tr '[:upper:]' '[:lower:]') +tier_var="OLLIE_TIER_${tier_upper}_${backend_lower}" +MODEL="${!tier_var:-}" + +if [ -z "$MODEL" ]; then + # Legacy fallback + case "$tier" in + worker) MODEL="${OLLIE_CASCADE_MODEL:-mistralai/devstral-small}" ;; + expert) MODEL="${OLLIE_ESCALATE_MODEL:-anthropic/claude-sonnet-4-20250514}" ;; + esac +fi + +# Agent config +case "$tier" in + worker) agent="worker" ;; + expert) agent="expert" ;; +esac + id="${id:-route-${tier}-$(date +%s%N)-$$}" [ -n "$OLLIE_SESSION_ID" ] && id="${OLLIE_SESSION_ID}__${id}"