route: per-backend tier model mapping, --backend flag

- Resolves model from OLLIE_TIER_{WORKER|EXPERT}_{backend}
- Falls back to legacy OLLIE_CASCADE_MODEL/OLLIE_ESCALATE_MODEL
- --backend flag lets orchestrator pick a different backend
- Inherits parent session's backend by default
- OLLIE_ENABLED_BACKENDS documents available backends
- README updated with tier config examples
This commit is contained in:
Ollie Agent 2026-05-20 09:30:55 +02:00
parent 4b6562b6f2
commit 9465e2f4a8
3 changed files with 44 additions and 11 deletions

View File

@ -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.

View File

@ -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: ["<instruction>"]}]
call_tool: calls=[{tool: "route", args: ["<instruction>", "--tier=worker"]}]
call_tool: calls=[{tool: "route", args: ["<instruction>", "--tier=expert"]}]
call_tool: calls=[{tool: "route", args: ["<instruction>", "--tier=expert", "--backend=anthropic"]}]
```
Parallel fan-out:
@ -35,3 +38,4 @@ SUMMARY: <result>
- 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.

View File

@ -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: <instruction> [--tier=worker|expert] [id]
# Args: <instruction> [--tier=worker|expert] [--backend=<name>] [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}"