"""Print the Agent tool's model and effort for a subagent's task: docs/decisions.md → `routing:`. usage: subagent-rung is the project's model, such as claude-opus-5-5, and 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 , 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