Documentation
¶
Overview ¶
modelgate refuses a sub-agent launched with the wrong model for its task.
modelgate --hook # a PreToolUse hook on the Agent tool modelgate --explain "Review PR 12" # which class a description falls in
⛔ WHY IT EXISTS. The routing rule — haiku for search, inventory and page checks; sonnet for anything that implements, releases or maintains; opus only for bibliography, design and review — was REMEMBERED and never enforced. Measured 2026-11-19 over 48 hours and 14,607 API calls: haiku got 8 calls, an opus agent reviewed a Renovate config PR, and 509 sub-agent calls ran on an outdated claude-opus-5. A rule that lives only in a prompt is followed when the prompt is in view and forgotten when it is not.
The decision, in the order it is taken ¶
not the Agent tool allow, silently
payload cannot be decoded allow, with a notice (a refusal is not a verdict)
subagent_type "fork" allow: a fork ignores the model
"model-waiver: <reason>" allow, the reason echoed as a stamped notice
model missing REFUSE: the environment default is sonnet,
which hides the choice
task unclassified allow, with any explicit model
model family != class's REFUSE, naming class, matched word and model
How a task is classified ¶
From the description (3 to 5 words), or the first line of the prompt when there is no description. Both are lowered and cut into words, and the EARLIEST word that appears in the table decides: "Fix review findings" is an implement task, "Review the fix" a review. A word matches WHOLE, so "fix" does not match "prefix" nor "review" "preview". Words in no class leave the task unclassified, and an unclassified task is never refused on its model — ambiguity must not turn into a false refusal.
The table is in longHelp, generated from the same variable the code reads.