Answer architecture round 1: 0 🔴, 5 🟡; one Agent-tool spelling of a rung, subagent-rung in its own package, its bounds tested, and the project's rung named again after each unfinished verdict

This commit is contained in:
2026-10-15 00:12:38 +02:00
parent 258b7e4de5
commit 52a370d78a
13 changed files with 41 additions and 30 deletions
+3 -3
View File
@@ -11,9 +11,9 @@ class Rung:
def flags(self) -> list[str]:
return ["--model", self.model, *(["--effort", self.effort] if self.effort else [])]
def family(self) -> str:
"""The model's family, such as opus, which the Agent tool takes as its model and runs that family's latest model; each rung names its family's latest, so the two match."""
return self.model.split("-")[1]
def agent_args(self) -> str:
"""The rung as the Agent tool takes it, which runs the named family's latest model; each rung names its family's latest, so the two match."""
return f"model {self.model.split('-')[1]}, effort {self.effort}"
# The archive records this wording, and loop_claude.routing.ROUTED reads it back to resume a chunk on its rung.
def __str__(self) -> str:
-43
View File
@@ -1,43 +0,0 @@
"""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
-42
View File
@@ -1,42 +0,0 @@
import pathlib
import subprocess
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from model_routing import subagent
TOOL = pathlib.Path(__file__).resolve().parents[1] / "subagent-rung"
class SubagentRung(unittest.TestCase):
def run_tool(self, *args: str) -> subprocess.CompletedProcess[str]:
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, text=True)
def test_prints_the_agent_tools_model_and_effort_for_the_rung_an_r_plus_c_picks(self):
self.assertEqual(subagent.agent_args("claude-opus-5-5", 9), "model opus, effort medium")
self.assertEqual(subagent.agent_args("claude-opus-5-5", 7), "model sonnet, effort high")
self.assertEqual(subagent.agent_args("claude-opus-5-5", 20), "model fable, effort max")
self.assertEqual(subagent.agent_args("claude-haiku-5-5", 2), "model haiku, effort low")
def test_picks_nothing_for_a_model_off_the_ladder(self):
self.assertIsNone(subagent.agent_args("claude-opus-5", 9))
def test_refuses_an_r_plus_c_outside_2_to_20_or_a_wrong_count_of_arguments(self):
for argv in (["claude-opus-5-5", "1"], ["claude-opus-5-5", "21"], ["claude-opus-5-5", "x"], ["claude-opus-5-5"], ["9", "claude-opus-5-5"]):
result = self.run_tool(*argv)
self.assertEqual((result.returncode, result.stdout), (1, ""), argv)
self.assertIn("usage: subagent-rung <model> <R+C>", result.stderr)
def test_the_launcher_prints_the_rung_and_exits_0_on_and_off_the_ladder(self):
on = self.run_tool("claude-opus-5-5", "12")
self.assertEqual((on.returncode, on.stdout, on.stderr), (0, "model opus, effort high\n", ""))
off = self.run_tool("claude-opus-5", "12")
self.assertEqual((off.returncode, off.stdout), (0, ""))
self.assertEqual(off.stderr, "subagent-rung: claude-opus-5 is not on the routing ladder; pass the Agent tool no model or effort\n")
self.assertIn("usage: subagent-rung <model> <R+C>", self.run_tool("--help").stdout)
if __name__ == "__main__":
unittest.main()