diff --git a/canon/orchestration.md b/canon/orchestration.md index cede6d0..bef7dac 100644 --- a/canon/orchestration.md +++ b/canon/orchestration.md @@ -27,9 +27,10 @@ present; nothing here names one. Read on demand: `sisi delegate guide`. - Give each task to the least expensive worker that is sufficiently capable, counting rework as cost: cheap work that must be redone is expensive. -- Evidence decides, in this order: the judged record for that kind of task and - difficulty; then price; then benchmark standing. A thin record is a reason - for care, not a verdict. +- Evidence decides which workers are capable enough, in this order: the judged + record for that kind and difficulty, the nearest judged record, then benchmark + standing against other workers' standing (never against an accepted rate); the + cheapest capable worker wins. A thin record is a reason for care, not a verdict. - Ask `sisi route --kind K --difficulty N` before delegating; `--explain` says why. Difficulty is 1 routine, 2 ordinary, 3 hard. Say the guess out loud; the record shows how good the guesses were. diff --git a/docs/design.md b/docs/design.md index 38990f2..a3902a5 100644 --- a/docs/design.md +++ b/docs/design.md @@ -284,9 +284,10 @@ worker). restricts routing to matching models of one provider; both are honoured by `sisi route`. `sisi workers down --until` accepts a date or a time, after which the worker is usable again. - `sisi route --kind K --difficulty N [--explain]`: the recommendation. Candidates are only - workers with a judged record, a known price or a benchmark prior. With a thin record it - ranks by price and prior instead of arbitrarily, and about one low-stakes task in ten goes - to a cheaper worker with a thin record. `sisi workers avoid|prefer PATTERN --why` holds the + workers with a judged record, a known price or a benchmark standing. It picks the cheapest + worker that is capable enough for the kind and difficulty (judged record, then the nearest + judged evidence, then benchmark standing against other standings, see docs/workers.md), and + about one low-stakes task in ten goes to a cheaper worker with a thin record. `sisi workers avoid|prefer PATTERN --why` holds the user's own constraints. - `sisi delegate judge …` is the only way a result enters the ledger (type, difficulty, worker, outcome, strongest check applied, minutes, tokens, retry-of). `amend` marks one that later diff --git a/docs/workers.md b/docs/workers.md index 1171920..37794d6 100644 --- a/docs/workers.md +++ b/docs/workers.md @@ -13,9 +13,13 @@ or learned from judged results. The strategy is [canon/orchestration.md](../cano record as three tables: by task type and difficulty (attempts, accepted, checked well, later wrong, median minutes; thin rows marked), what fixed each rejection, and difficulty-guess calibration. -- `sisi workers fact WORKER --price N|--score N --source S [--date D] [--plan flat|per-use] - [--maker M]` — record a price (per million tokens) or a benchmark standing (0–100), each with - its source and date, in the user store. A fact without a source is refused. +- `sisi workers fact WORKER --price-in N --price-out N | --price N | --standing N --source S + [--date D] [--plan flat|per-use] [--maker M]` — record a price as published (input and output, + per million tokens), one blended price for a source that publishes only that, or a benchmark + standing (0–100; `--score` is the old name), each with its source and date, in the user store. + A fact without a source is refused. Ranking uses one blend of the two prices, by default three + parts input to one part output (`route.price_blend_input_parts`); `sisi workers` shows both + prices and the blend, and lists each benchmark standing apart from the accepted rates it prints. - `sisi workers avoid|prefer PATTERN --why TEXT` — the user's own routing constraints. - `sisi workers only PROVIDER PATTERN... --why TEXT` — only the matching models of that provider are routable; anything else from it (a newly discovered model, say) is passed over with the reason. @@ -47,7 +51,7 @@ or learned from judged results. The strategy is [canon/orchestration.md](../cano ## How the choice is made -Candidates are only workers with a judged record, a known price or a benchmark prior; discovered +Candidates are only workers with a judged record, a known price or a benchmark standing; discovered catalogue models with none of those are listed but never routed to. On a cold start nobody qualifies: the pick is then a trial among usable workers, `--explain` says so, and asks for the result to be judged and facts recorded. @@ -55,12 +59,24 @@ result to be judged and facts recorded. In order: a tier that trains on prompts is never chosen; unavailable and allowance-spent workers are skipped and named; `avoid` patterns remove a worker unless that leaves nobody; a reviewer comes from a different maker than the author (a stored `maker` fact, else derived from the model -id). Proven workers (enough attempts at or above the accepted-rate bar, not later found wrong) -come first above difficulty 1; proven-bad workers are passed over. Cheapest first within that: -flat-rate allowance before per-use prices, unknown prices last, the benchmark prior ordering a -thin record at equal price, `prefer` patterns first, then load balancing across allowances. -About one difficulty-1 task in ten goes to a cheaper thin-record worker instead, so cheaper -options gather evidence. The choice is deterministic for one fixed record. +id). Then the cheapest worker that is capable enough for the kind and difficulty, judged by the +best evidence about each worker, in this order: (a) its judged record for that kind and +difficulty (enough attempts at or above the accepted-rate bar, not later found wrong); (b) the +nearest judged evidence: the same kind at a harder difficulty proves an easier one, then all +kinds at that difficulty or a harder one (the same kind at an easier difficulty is weak evidence, +used only when no usable worker is capable otherwise); (c) benchmark standing as a prior, compared +only with other workers' standing: at least 85 percent of the best usable standing for difficulty +3, 60 percent for difficulty 2, no floor for difficulty 1 (`route.standing_floor` in the config); +(d) nothing known: difficulty 1 only, as an exploration. A thick bad record at this or an easier +difficulty, or a thin one with repeated rejections, keeps a worker off its benchmark. The two +scales never meet: a standing is never compared with an accepted rate. Cheapest first among the +capable: flat-rate allowance before per-use prices (blended input and output), unknown prices +last, then standing, `prefer` patterns first, then load balancing across allowances. When no +worker is capable by the evidence, the strongest known usable worker is recommended and `--explain` +says that none is proven. About one difficulty-1 task in ten goes to a cheaper thin-record worker +instead, so cheaper options gather evidence. The choice is deterministic for one fixed record. +`--explain` prints one line for the evidence behind the choice (which of a to d, with the numbers), +one per group of workers passed over as not capable enough, and names an exploration or a fallback. ## Costs and failures diff --git a/sisi/routing.py b/sisi/routing.py index e0b13c7..2d9242d 100644 --- a/sisi/routing.py +++ b/sisi/routing.py @@ -528,10 +528,10 @@ def _why_not(a, difficulty, basis, cheaper): def retry_choice(candidates, records, availability, kind, difficulty, rejected, rejections, now=0.0, exclude=(), avoid=None, prefer=None, floors=None, review_of=None): """Who gets a task again after `rejected` (a worker id) was rejected `rejections` times in this chain. - The first retry goes back to the same worker while it is still usable and has no poor record. After that: the cheapest - capable worker whose evidence is strictly better than the rejected one's, or, when there is none, + The first retry goes back to the same worker while it is still usable and has no poor record. + After that: the cheapest capable worker whose evidence is strictly better than the rejected one's, or, when there is none, the strongest known usable worker other than it (and only the rejected one itself when nobody - else is usable). Returns {"choice", "step", "assessments", "basis", ...}; step is "same", "better", + else is usable). Returns {"choice", "step", "assessments", ...}; step is "same", "better", "strongest" or "only", and choice is None when nobody is usable. Pure; the caller supplies facts.""" now = float(now or 0) eligible, passed, stats, author_maker = _prepare(candidates, records, availability, now, exclude, avoid, review_of)