41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
"""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, in the Agent tool's words, such as `model sonnet, effort high`. For a model
|
|
off the routing ladder, the tool prints nothing on stdout, says so on stderr and exits 0; launch the
|
|
subagent with 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)
|
|
return picked(anchor, risk_and_complexity).agent_args() if anchor else None
|
|
|
|
|
|
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) if argv else ''}; {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
|