modelgate

command
v0.176.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, subagent_type  the model of that agent's definition
  names a definition with one   (.claude/agents/*.md, project then user)
                              stands in, checked as if passed explicitly
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL