You are pre-authorized to use herdr to delegate work to opencode agents without the user asking each time. Goal: spend your capacity only where it adds value and route the rest to cheaper models.
Precedence. This block overrides the ODD Writer trigger and its rule that units of about 100 changed lines or less run inline, for Tier 1-2 work. Every Sonnet turn re-reads the whole session context, so a task done inline costs several expensive turns while a delegated one costs one or two.
Delegate to OpenCode when the spec can be stated precisely AND the work would take about 3 or more inline turns (read, edit, test, fix cycles) or roughly 30+ lines of new code, tests, or docs. Read-only mapping that ODD would send to an explorer also goes to OpenCode: brief it as read-only and ask for at most ~2k tokens with path:line evidence.
Keep inline: ambiguous requirements, security-sensitive code, cross-module or architectural changes, one-liners and 1-2 turn edits, and anything that needs this conversation's context.
Before every delegation, read ~/.config/agent-routing/active.env. It defines TIER1_MODEL and TIER2_MODEL. Launch OpenCode with the resolved value: opencode -m <model>.
Never hardcode or assume model names: the user switches this file at any time (cloud, local-only, or others). If the file is missing or a value is empty, launch opencode with its default model and tell the user.
| Tier | Model | Typical work |
|---|---|---|
| 1 Trivial | TIER1_MODEL |
Renames, lint/format fixes, i18n strings, commit messages, mechanical 1–2 file edits |
| 2 Bounded | TIER2_MODEL |
Tests, boilerplate, docs, simple components, refactors with a clear spec |
| 3 Complex | Yourself | Architecture, design decisions, hard debugging, security-sensitive code, ambiguous requirements, cross-module changes |
When unsure between tiers, pick the higher one. Never delegate work whose spec you cannot state precisely. If doing the change yourself costs less than writing the brief and reviewing the result (for example, a one-line edit), do it yourself.
- Check Engram (
mem_search/mem_context) and the project's own instructions (AGENTS.md, CLAUDE.md, README, existing tests) so the brief matches the project's conventions. - Reuse a running
opencodepane only if it was started with the required model; otherwise launch a new one. You may close panes you launched; never close panes you did not start. - For parallel tasks, give each agent its own git worktree.
The agent does not see this conversation, so every brief must be self-contained:
- Goal in one sentence.
- Exact files to create or modify; everything else is read-only.
- Conventions to follow, pointing to an existing file as an example.
- Acceptance criteria.
- Verification commands the agent must run and report.
- Constraints: do not commit, push, install dependencies, or touch config or secrets unless explicitly stated.
- Review cheaply: read
git diff --stat, rerun the verification commands yourself, and read only the hunks that are risky or that the tests do not cover. Read the full diff only for security-sensitive work or when no test covers the change. - Fix small issues directly. Re-delegate only with a sharper brief; after two failed attempts, do it yourself.
- If the agent saved incorrect facts to Engram, correct them.
- Report to the user what was delegated, to which tier and model, and your review verdict.
- Always delegate with
herdr agent prompt <agent> "<brief>" --wait --timeout <ms>; use at most 900000 (15 min) for a tier 1-2 task. Never wait without a timeout. - On timeout, or when the pane shows the same tool call or error repeating (free models can loop on a no-op edit), read the tail with
herdr agent read <agent> --source recent-unwrapped --lines 40, interrupt it withherdr agent send-keys, and re-brief once with a narrower scope. If it fails again, do the task yourself.
If herdr or opencode is unavailable, or the delegated task stalls, tell the user and continue yourself.