Answer architecture round 1: 1 🔴, 5 🟡; track bin/model_routing, hand over the route by its rung, share the R + C mapping, record the routing item, and have the judge report R + C plainly
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""The routing ladder, and the step an R + C moves a task from the project's rung: docs/decisions.md → `routing:`."""
|
||||
import dataclasses
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Rung:
|
||||
model: str
|
||||
# Empty leaves the effort to claude's default for the model, as for a model off the ladder.
|
||||
effort: str = ""
|
||||
|
||||
def flags(self) -> list[str]:
|
||||
return ["--model", self.model, *(["--effort", self.effort] if self.effort else [])]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.model} at {self.effort} effort" if self.effort else self.model
|
||||
|
||||
|
||||
# Least competent first. The Artificial Analysis Intelligence Index orders every rung but the top one, keeping a rung only
|
||||
# where no cheaper rung scores as high; Fable 5.1 tops the ladder as Anthropic's most capable model, which the index does not show.
|
||||
LADDER = (
|
||||
Rung("claude-haiku-5-5", "low"),
|
||||
Rung("claude-haiku-5-5", "medium"),
|
||||
Rung("claude-haiku-5-5", "high"),
|
||||
Rung("claude-haiku-5-5", "xhigh"),
|
||||
Rung("claude-haiku-5-5", "max"),
|
||||
Rung("claude-sonnet-5-5", "high"),
|
||||
Rung("claude-opus-5-5", "medium"),
|
||||
Rung("claude-opus-5-5", "high"),
|
||||
Rung("claude-opus-5-5", "xhigh"),
|
||||
Rung("claude-opus-5-5", "max"),
|
||||
Rung("claude-fable-5-1", "max"),
|
||||
)
|
||||
# (highest R + C in the band, rungs it steps from the project's rung); a higher R + C steps ABOVE_THE_BANDS.
|
||||
BANDS = ((4, -3), (6, -2), (8, -1), (10, 0), (12, 1), (14, 2), (16, 3))
|
||||
ABOVE_THE_BANDS = 4
|
||||
|
||||
|
||||
def project_rung(model: str) -> int | None:
|
||||
"""The index of the model's cheapest rung, which for Opus 5.5 is its default effort; None for a model off the ladder."""
|
||||
return next((index for index, rung in enumerate(LADDER) if rung.model == model), None)
|
||||
|
||||
|
||||
def steps(risk_and_complexity: int) -> int:
|
||||
return next((step for highest, step in BANDS if risk_and_complexity <= highest), ABOVE_THE_BANDS)
|
||||
|
||||
|
||||
def climbed(index: int, by: int) -> int:
|
||||
"""The rung by steps from index, stopping at either end of the ladder."""
|
||||
return max(0, min(len(LADDER) - 1, index + by))
|
||||
|
||||
|
||||
def picked(anchor: int, risk_and_complexity: int) -> int:
|
||||
"""The rung a task's R + C picks from anchor, the project's rung."""
|
||||
return climbed(anchor, steps(risk_and_complexity))
|
||||
|
||||
|
||||
def index_of(rung: Rung) -> int | None:
|
||||
return LADDER.index(rung) if rung in LADDER else None
|
||||
@@ -0,0 +1,41 @@
|
||||
import pathlib
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from model_routing.ladder import climbed, LADDER, project_rung, Rung, steps
|
||||
|
||||
|
||||
class Ladder(unittest.TestCase):
|
||||
def test_runs_from_haiku_at_low_effort_to_fable_at_max_with_opus_at_medium_between(self):
|
||||
self.assertEqual(LADDER[0], Rung("claude-haiku-5-5", "low"))
|
||||
self.assertEqual(LADDER[-1], Rung("claude-fable-5-1", "max"))
|
||||
self.assertEqual(len(LADDER), 11)
|
||||
self.assertEqual(len(set(LADDER)), len(LADDER))
|
||||
|
||||
def test_puts_a_project_on_its_models_cheapest_rung_and_none_off_the_ladder(self):
|
||||
self.assertEqual(LADDER[project_rung("claude-opus-5-5")], Rung("claude-opus-5-5", "medium"))
|
||||
self.assertEqual(LADDER[project_rung("claude-sonnet-5-5")], Rung("claude-sonnet-5-5", "high"))
|
||||
self.assertIsNone(project_rung("claude-opus-5"))
|
||||
self.assertIsNone(project_rung("opus"))
|
||||
|
||||
def test_steps_each_band_of_r_plus_c_from_the_projects_rung(self):
|
||||
self.assertEqual([steps(total) for total in range(2, 21)], [-3, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4])
|
||||
|
||||
def test_a_step_past_either_end_stops_there(self):
|
||||
opus = project_rung("claude-opus-5-5")
|
||||
self.assertEqual(LADDER[climbed(opus, steps(4))], Rung("claude-haiku-5-5", "xhigh"))
|
||||
self.assertEqual(LADDER[climbed(opus, steps(17))], Rung("claude-fable-5-1", "max"))
|
||||
self.assertEqual(climbed(0, -3), 0)
|
||||
self.assertEqual(climbed(len(LADDER) - 1, 1), len(LADDER) - 1)
|
||||
|
||||
def test_passes_the_effort_only_where_the_rung_names_one(self):
|
||||
self.assertEqual(Rung("claude-opus-5-5", "high").flags(), ["--model", "claude-opus-5-5", "--effort", "high"])
|
||||
self.assertEqual(Rung("worker-model").flags(), ["--model", "worker-model"])
|
||||
self.assertEqual(str(Rung("claude-opus-5-5", "high")), "claude-opus-5-5 at high effort")
|
||||
self.assertEqual(str(Rung("worker-model")), "worker-model")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user