Route the worker's subagents by their task's R + C, and keep seats and the security pass on the project's rung

This commit is contained in:
2026-10-15 00:09:22 +02:00
parent 1d00d3ee82
commit 258b7e4de5
14 changed files with 123 additions and 24 deletions
+43
View File
@@ -0,0 +1,43 @@
"""Print the Agent tool's model and effort for a subagent's task: docs/decisions.md → `routing:`.
usage: subagent-rung <model> <R+C>
<model> is the project's model, such as claude-opus-5-5, and <R+C> the task's R + C, a whole
number from 2 to 20, scored as for a todo.md item. It prints the rung that R + C picks from the
model's cheapest rung, as the Agent tool takes it: `model sonnet, effort high`. A model off the
routing ladder routes nothing: it prints nothing, says so on stderr and exits 0, and the subagent
takes no model or effort.
Exit 1, saying why, on bad arguments.
"""
import re
import sys
from model_routing.ladder import picked, project_rung
USAGE = "usage: subagent-rung <model> <R+C>, R+C a whole number from 2 to 20"
def agent_args(model: str, risk_and_complexity: int) -> str | None:
"""The Agent tool's model and effort for the rung risk_and_complexity picks from model's cheapest rung; None for a model off the ladder."""
anchor = project_rung(model)
if anchor is None:
return None
rung = picked(anchor, risk_and_complexity)
return f"model {rung.family()}, effort {rung.effort}"
def main(argv: list[str]) -> int:
if argv[:1] in (["-h"], ["--help"]):
print(__doc__.strip())
return 0
if len(argv) != 2 or not re.fullmatch(r"[2-9]|1[0-9]|20", argv[1]):
print(f"subagent-rung: cannot read the arguments {' '.join(argv)}; {USAGE}", file=sys.stderr)
return 1
model, total = argv
args = agent_args(model, int(total))
if args is None:
print(f"subagent-rung: {model} is not on the routing ladder; pass the Agent tool no model or effort", file=sys.stderr)
else:
print(args)
return 0