Integration 3, 4, 5: a learned worker is a worker everywhere (meter picks, delegation guard names provider/model, fallback uses provider phrases and probe reset, retry line); rule 6 text; playbook and docs/workers.md merged; config test. done / next: 6 (session-start lines), the tests per point
This commit is contained in:
1 parent
3c2aa9b395
commit
b3a68018c0
10 files changed
+100
-46
No files matched your search
@@ -100,15 +100,13 @@ present; nothing here names one. Read on demand: `sisi delegate guide`.
|
||||
worker: find current prices and software-engineering benchmark standing,
|
||||
then record them. Treat a newly appeared model as unproven: low-stakes
|
||||
tasks first, checked one level more carefully, until its record is thick.
|
||||
- Workers appear after sisi is installed. A new command-line tool is named once at session
|
||||
start (`sisi workers learn NAME` prints the brief for the cheap worker that learns it);
|
||||
what the host can reach is learned from its own capability listing and delegation calls.
|
||||
Either way a new worker is unproven: routine work only, a free or flat one tried more
|
||||
often, every result checked with at least the tests or a read of the diff, until its
|
||||
judged record decides.
|
||||
- One tool can carry several providers, each with its own plan, allowance and failure phrases
|
||||
(`sisi workers plan|allowance|signature`). The owner can vouch for a worker he checked himself
|
||||
(`sisi workers vouch`): capable up to that difficulty on his word until its own record decides.
|
||||
- Workers appear after sisi is installed: a new command-line tool is named once at session start
|
||||
(`sisi workers learn NAME` prints the brief for the cheap worker that learns it), and the host's
|
||||
own listing teaches the providers and models it reaches. A new worker is unproven: routine work
|
||||
only, checked with at least the tests or a read of the diff, until its judged record decides.
|
||||
- A tool can carry several providers, each with a plan, an allowance and failure phrases (`sisi
|
||||
workers plan|allowance|signature`). The owner can vouch for a worker (`sisi workers vouch`). A
|
||||
learned tool that switches off approvals, and an allowance probe, wait for the owner's `sisi approve`.
|
||||
- Orchestration legwork is delegable like any other legwork: discovery,
|
||||
price and benchmark research, routing lookups, first-pass review, and
|
||||
summarising the record can all go to a fast, cheap worker. The judgement
|
||||
|
||||
+2
-1
@@ -125,7 +125,8 @@ the budget and every other check run first, and a refusal applies nothing. If ap
|
||||
again is refused, and so is a second change to a rule that has one waiting. If the owner refuses, the
|
||||
learning is rejected, not proposed again.
|
||||
- **`sisi approve`** with no arguments lists every waiting change in full: the command, the pattern and
|
||||
profile, the rule text as a diff, why it needs the owner, and the replay result. A decision needs the word
|
||||
profile, the rule text as a diff, why it needs the owner, and the replay result. The same listing, word and
|
||||
record serve a learned tool that switches off approvals (`drv-NAME`) and an allowance probe (`probe-PROVIDER`). A decision needs the word
|
||||
`sisi approve ID --yes|--no` prints typed back at the controlling terminal device (never standard input), and
|
||||
the before-tool hook refuses any shell command of an agent that invokes it; a process with no controlling
|
||||
terminal is refused unless the user config sets `learning.agent_relayed_approval`. Every decision, and every
|
||||
|
||||
+8
-14
@@ -131,18 +131,12 @@ with no judged record, price or prior is listed but never routed to until eviden
|
||||
|
||||
## Workers that appear later
|
||||
|
||||
A worker that did not exist when sisi was installed becomes routable through ordinary use. Nothing is scheduled; each way in runs inside a hook or a command already run. The names of a host's tools and the shape of their data are in `canon/discovery.json` (data, never code).
|
||||
A worker that did not exist when sisi was installed becomes routable through ordinary use; nothing is scheduled. Host tool names are data (`canon/orchestration-tools.json`, shared with the orchestration meter), never code.
|
||||
|
||||
- **From the host.** The after-tool hook (`sisi watch --after`) recognises the host's capability-listing tool and its delegation tool by the patterns in that file. A listing adds every provider the host says can run a task, each model as the worker `provider/model` exactly as the host names it (a provider the host disables is recorded but never routable). A provider missing from `discovery.drop_after_listings` listings (default 3) is dropped. A delegation seen passing is recorded too. Once per set of new workers the agent gets one line with the count. `sisi route` names the host's delegation tool and the provider and model ids to pass it. A provider listing more than `discovery.catalogue_over` models (default 8) is a catalogue: its models are stored, and only those used, priced or with a standing are candidates. Kept in the scratch folder (`discovery/host-workers.json`); the next listing rebuilds it.
|
||||
- **From PATH.** At session start the executables in the user-level folders on PATH (under the home folder, never system folders; nothing is run) are compared with the stored list. It is looked at again when a folder changed, after `discovery.path_refresh_s` (6 hours) or `discovery.path_every_starts` (25) session starts. The first run only stores the list. New names are announced once, five at most.
|
||||
- **A driver, learned as data.** `sisi workers learn NAME` prints a delegation contract for a fast, cheap worker: read the tool's own help, write a small JSON file (the fields of the built-in driver table, plus failure phrases and a token pattern). `--check FILE` validates it; `--record FILE` validates, stores it (`worker-drivers.json`, with who learned it and when) and runs ONE read-only smoke task in a temporary folder, with a time limit and no input. Only a passing driver is used; a failure is classified (login, quota, bad template, no answer, timeout) and the driver stays unusable with the reason (`--verify` tries again). The command is an argument list run without a shell; the brief is one argument. A command with a flag that switches off approvals or a sandbox (patterns in the data file) waits for `sisi approve drv-NAME`, which shows the exact command, and never runs, smoke task included, before. `sisi workers forget NAME` removes one.
|
||||
- **Earning a place.** Such a worker is unproven until it has `MIN_ATTEMPTS` judged attempts: difficulty 1 only, whatever benchmark it has; a free or flat one gets one routine task in `route.explore_free_one_in` (default 3); `sisi route` and `sisi delegate` say to check its result with at least the tests or a read of the diff. Its plan comes from its driver or from a fact; unknown counts as per-use. The missing-facts line at session start names the new workers (five at most) so the research has a target.
|
||||
|
||||
## One tool, several providers
|
||||
|
||||
A tool can carry several providers (the part of a worker id before the first slash). Each has its own facts in the user store, set by command and shown under the tool by `sisi workers`; a constraint or mark on one never reaches another (a pattern ending in `/`, such as `a-b/`, names one provider exactly; availability marks made for a provider reach its workers only).
|
||||
|
||||
- `sisi workers plan PROVIDER flat|free|per-use --source S [--note TEXT]` (`worker-providers.json`). A flat or free plan with allowance left costs nothing extra per task, as routing already treats a flat plan. A price fact on a model of a flat plan is its *relative cost inside the plan* (compared with other flat workers), so routine work goes to the lighter model; a model's own `--plan` fact still wins over the provider's.
|
||||
- `sisi workers vouch WORKER --up-to 1|2|3 --why "OWNER'S WORDS"` (`worker-vouches.json`): a new worker with no judged record is limited to routine work; the owner can vouch for one he checked himself. Routing then treats it as capable up to that difficulty, with the evidence named "the owner's word", ranked with judged records (proof before benchmark) and still checked a level more carefully. A thick bad record overrides it; once the worker has its own thick record the vouch is ignored. Like `sisi learn`, the command records whether the quoted words appear in a message the owner typed; otherwise it is stored as relayed by an agent and counts only up to difficulty 2.
|
||||
- `sisi workers allowance PROVIDER --url URL --header 'Name={secret}' --secret-from-command CMD --secret-path PATH --remaining-path PATH --reset-path PATH [--total-path PATH]` (or `--command CMD` for a tool that prints its own allowance). Paths: `a.b`, `[n]`, `[*]`, `[key=value]` (`[integrationID=x][active=true].value.key`), or `re:REGEX` with one group. It is read when `sisi workers` is asked, and when routing needs it and the cached reading is older than `discovery.allowance_cache_s` (300). The key comes from the named command at probe time (an argument list, no shell), goes in one request (https, or this machine; a redirect is never followed; `discovery.allowance_timeout_s`), and is never written to the store, cache, ledger or any output. Several windows: the smallest remaining decides whether the provider is out, and it is down until every exhausted window has reset. A probe that fails changes nothing and says so in `sisi workers` only. A probe waits for the owner (`sisi approve probe-PROVIDER`) unless defined in the owner's terminal. When a run reports a limit and a probe is defined, the reset time comes from the probe.
|
||||
- `sisi workers signature PROVIDER --match 'TEXT|re:REGEX' --class auth|limit|missing|error [--until-path PATH]`: the provider's own failure phrases, consulted before the built-in ones; an auth failure marks that provider down, not the whole tool.
|
||||
- **From the host.** The after-tool hook reads the host's capability listing and delegation calls. Each provider the host says can run a task, and each model, is the worker `provider/model`; a provider the host disables is stored, never routable, and one missing from `discovery.drop_after_listings` listings (3) is dropped. A listing over `discovery.catalogue_over` models (8) is a catalogue: only models used, priced or with a standing are candidates. `sisi route` names the delegation tool and the ids to pass it. Your own `only` limit still decides what is routable.
|
||||
- **From PATH.** Session start compares the executables in the user-level folders on PATH (nothing is run) with the stored list and names new ones once, five at most (`discovery.path_refresh_s`, `discovery.path_every_starts`).
|
||||
- **A tool, learned as data.** `sisi workers learn NAME` prints the brief for a cheap worker to read the tool's help and write a small JSON driver; `--check FILE` validates, `--record FILE` stores it (`worker-drivers.json`) and runs one smoke task, `--verify` retries, `sisi workers forget NAME` removes it. The command is an argument list, never a shell. A name that collides with a built-in driver is refused. A command with a flag that switches off approvals or a sandbox runs nothing until the owner decides.
|
||||
- **Earning a place.** Such a worker is unproven until it has `MIN_ATTEMPTS` judged attempts: difficulty 1 only, a free or flat one gets one routine task in `route.explore_free_one_in` (3), and `sisi route`/`sisi delegate` say to check its result. Unknown plan counts as per-use.
|
||||
- **Providers.** A tool can carry several providers (the part of an id before the first slash), each with facts of its own that never reach another: `sisi workers plan PROVIDER flat|free|per-use --source S`; `sisi workers allowance PROVIDER --url|--command ...` (a probe: the key comes from a named command at probe time, goes in one request, and is never stored or printed; the smallest remaining window decides, the provider is down until every spent window resets; a failed probe changes nothing); `sisi workers signature PROVIDER --match TEXT --class auth|limit|missing|error` (the provider's own failure phrases, before the built-in ones). A limit marks that provider down until the time the error names, else the probe's reset.
|
||||
- **Vouching.** `sisi workers vouch WORKER --up-to 1|2|3 --why "OWNER'S WORDS"`: capable up to that difficulty on the owner's word, ranked with judged proof, shown by `--explain` as its own evidence; a thick bad record overrides it and its own thick record replaces it. Words not found in a message the owner typed count only to difficulty 2.
|
||||
- **The owner's decisions.** Learned drivers that switch off approvals (`drv-NAME`) and allowance probes (`probe-PROVIDER`) are decided with learning changes by one command, `sisi approve`: it lists all three kinds in full, and a decision needs the random word it prints typed at the controlling terminal. An agent's shell command is refused, whatever the id.
|
||||
+2
-2
@@ -1241,7 +1241,7 @@ def park_rule_change(action, reasons):
|
||||
return pid
|
||||
|
||||
|
||||
def _waiting():
|
||||
def _owner_waiting():
|
||||
"""Everything that waits for the owner, of all three kinds, as dicts with "id", "lines" (the full action) and
|
||||
"apply" (yes -> (exit code, text)): a learning change (P-N), a learned driver (drv-NAME), an allowance
|
||||
probe (probe-PROVIDER). One list, one ask."""
|
||||
@@ -1275,7 +1275,7 @@ def waiting_count():
|
||||
|
||||
|
||||
def cmd_approve(argv):
|
||||
waiting = _waiting()
|
||||
waiting = _owner_waiting()
|
||||
if not argv:
|
||||
if not waiting:
|
||||
print("nothing waits for a decision")
|
||||
|
||||
+14
-2
@@ -1021,6 +1021,9 @@ def annotate(cands, records, tools):
|
||||
if t.get("host"):
|
||||
c["host_native"] = True
|
||||
c["host_mechanism"] = host_mechanism(t, c["worker"])
|
||||
bare = host_route(t, c["worker"])[1]
|
||||
if bare and bare not in c["aliases"]: # a failure notice names the model as the host's tool does, without the provider
|
||||
c["aliases"] = list(c.get("aliases") or []) + [bare]
|
||||
return cands
|
||||
|
||||
|
||||
@@ -1552,9 +1555,11 @@ def routing_provider(c):
|
||||
return routing.provider_of(c.get("worker"))
|
||||
|
||||
|
||||
def apply_allowances(cands, now=None, force=False):
|
||||
def apply_allowances(cands, now=None, force=False, cached_only=False):
|
||||
"""Read each defined probe (when its cached reading is old), set the candidates' allowance, and mark a provider
|
||||
whose allowance is spent as down until the reset it reports. Returns the set of providers that are spent now."""
|
||||
whose allowance is spent as down until the reset it reports. Returns the set of providers that are spent now.
|
||||
With `cached_only` (a hook) nothing is asked of a provider and nothing is recorded: the last reading, however
|
||||
old, only sets the candidates' allowance."""
|
||||
probes = _probes()
|
||||
spent = set()
|
||||
if not probes:
|
||||
@@ -1562,6 +1567,13 @@ def apply_allowances(cands, now=None, force=False):
|
||||
from . import workers
|
||||
now = time.time() if now is None else now
|
||||
for prov, d in probes.items():
|
||||
if cached_only:
|
||||
reading = _load(allowance_cache()).get(prov)
|
||||
st = allowance_state(reading) if isinstance(reading, dict) and reading.get("ok") else None
|
||||
for c in cands:
|
||||
if st and routing_provider(c) == prov:
|
||||
c["allowance_pct_left"] = 0.0 if st["exhausted"] else st["pct"]
|
||||
continue
|
||||
reading = read_allowance(prov, d, now, force)
|
||||
st = allowance_state(reading) if reading.get("ok") else None
|
||||
if st is None:
|
||||
|
||||
+6
-4
@@ -88,10 +88,12 @@ def handle(m, sid, cwd, text, own_model=None, worker=None, run_id=None, record=T
|
||||
"""A failure message arrived. Classify it; record the worker down (when it can be identified and `record`);
|
||||
mark its pending run superseded; remember it in the meter for the question-dialog check; return the fallback
|
||||
text, or None when the text is not an unavailability. Never raises past the caller's guard."""
|
||||
if workers.classify_failure(text) is None:
|
||||
return None
|
||||
from . import orchestration
|
||||
worker = worker or workers.identify_worker(text)
|
||||
cand = workers.resolve_worker(worker, workers._cached_candidates()[0]) if worker else None
|
||||
failure = workers.failure_for(text, cand) # with the worker's provider's phrases and its learned driver's
|
||||
if failure is None:
|
||||
return None
|
||||
info = {"worker": worker, "ts": time.time(), "kind": kind, "difficulty": difficulty}
|
||||
run, marked = None, None
|
||||
if run_id:
|
||||
@@ -106,7 +108,7 @@ def handle(m, sid, cwd, text, own_model=None, worker=None, run_id=None, record=T
|
||||
due = workers.read_availability().get(str(worker).lower()) or {}
|
||||
info.update(until=due.get("retry_at"), reason=("%s: %s" % (due.get("reason"), (due.get("note") or "")[:60])) if due else None)
|
||||
if not info.get("reason"):
|
||||
reason, note, _ = workers.classify_failure(text)
|
||||
reason, note, _ = failure
|
||||
info["reason"] = "%s: %s" % (reason, note[:60])
|
||||
if run_id:
|
||||
workers.append_record({"kind": "run-end", "run_id": run_id, "ts": round(time.time()), "status": "superseded",
|
||||
@@ -117,7 +119,7 @@ def handle(m, sid, cwd, text, own_model=None, worker=None, run_id=None, record=T
|
||||
for part in re.split(r"[/\s]+", str(n or "").lower()):
|
||||
if len(part) >= 4:
|
||||
names.add(part)
|
||||
names.update(("fallback", "fall back", "unavailable") + _REASON_WORDS.get(workers.classify_failure(text)[0], ()))
|
||||
names.update(("fallback", "fall back", "unavailable") + _REASON_WORDS.get(failure[0], ()))
|
||||
m["unavail_names"] = sorted(names)
|
||||
orchestration._event(m, sid, "unavailable", worker=worker, run=run_id)
|
||||
return fallback_text(info, cwd, own_model)
|
||||
@@ -645,10 +645,13 @@ def _before_delegation(payload, hd, tool, inp, host, sid, sess, m, c, cwd):
|
||||
return {"deny": route_text()}
|
||||
import uuid
|
||||
run_id = uuid.uuid4().hex[:8]
|
||||
worker = model or own or "(inherited)"
|
||||
provider = _dig(inp, spec.get("provider")) if spec.get("provider") else None
|
||||
provider = provider.strip() if isinstance(provider, str) else ""
|
||||
# a delegation that names a provider (the host's cross-provider tool) is the worker `provider/model`, as discovery names it
|
||||
worker = ("%s/%s" % (provider, model) if provider and model and "/" not in model else model) or own or "(inherited)"
|
||||
against = None
|
||||
if route and route.get("worker"):
|
||||
against = not workers.same_model(worker, route["worker"])
|
||||
against = not workers.same_worker(worker, route["worker"], bool(provider))
|
||||
try:
|
||||
workers.append_record({"kind": "run", "id": run_id, "ts": round(now),
|
||||
"type": (route or {}).get("kind"), "difficulty": (route or {}).get("difficulty"),
|
||||
|
||||
+17
-3
@@ -180,15 +180,29 @@ def _orchestrate():
|
||||
if _has("workers", "retry_context") and _has("routing", "retry_choice") else None,
|
||||
"the before-tool hook answers one refusal at a time, in a fixed order: workers are exempt, then the contract "
|
||||
"guard, then the delegation guard, then the direct-work budget (sisi/watch.py)"
|
||||
if meter and _guard_scope() else None],
|
||||
if meter and _guard_scope() else None,
|
||||
"a worker learned by use (a command-line tool's driver, a provider and model the host lists) is unproven: "
|
||||
"offered routine work only unless the owner vouched, its result carries the check-it line, and a learned "
|
||||
"command runs without a shell after a smoke task (sisi/discovery.py, sisi/routing.py)"
|
||||
if _has("discovery", "annotate", "prove") and _has("routing", "vouch_level") else None,
|
||||
"a learned tool that switches off approvals, and an allowance probe, wait for the owner's own decision: the same "
|
||||
"typed word at the terminal as a learning change, refused to an agent by the before-tool hook, every decision "
|
||||
"and refused attempt recorded (sisi/cycle.py, sisi/watch.py, sisi/discovery.py)"
|
||||
if _has("discovery", "waiting_decisions") and _has("cycle", "cmd_approve") else None,
|
||||
"a provider's own failure phrases and its allowance probe decide whether a failure is a limit or a login "
|
||||
"problem and when it is back; only that provider is marked down (sisi/discovery.py, sisi/workers.py)"
|
||||
if _has("discovery", "provider_failure", "limit_until") else None],
|
||||
measured=["the delegation ledger and `sisi delegate judge`, `sisi route` recommends the worker from that record (sisi/routing.py, sisi/workers.py)"
|
||||
if _has("routing", "choose") and _has("workers", "cmd_delegate") else None,
|
||||
"the unit record and `sisi status` show direct calls and characters, refusals, extensions with their reasons, "
|
||||
"delegations started, judged and unjudged, and the share of tool calls delegated (sisi/orchestration.py, sisi/scorecard.py)"
|
||||
if _has("orchestration", "telemetry") else None,
|
||||
"`sisi workers` shows how often the router was overridden and how the overrides turned out; a model discovery "
|
||||
"has not seen before is named once at session start as unproven (sisi/workers.py)"
|
||||
if _has("workers", "override_line", "new_worker_line") else None],
|
||||
"has not seen before, and a new command-line tool, are named once at session start (sisi/workers.py, sisi/discovery.py)"
|
||||
if _has("workers", "override_line", "new_worker_line") else None,
|
||||
"the owner's vouch for a worker is shown by `sisi workers` and `sisi route --explain` as its own kind of "
|
||||
"evidence, never as a judged record (sisi/discovery.py, sisi/routing.py)"
|
||||
if _has("discovery", "vouch_lines") else None],
|
||||
judgement=["who gets the task, how much to check what comes back, the quality of a brief"])
|
||||
|
||||
|
||||
|
||||
+38
-8
@@ -161,6 +161,13 @@ def classify_failure(text, returncode=0, extra=None):
|
||||
_ISO_TIME = r"\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?"
|
||||
|
||||
|
||||
def failure_for(text, cand=None, returncode=0):
|
||||
"""classify_failure with what is known of the worker: its provider's own recorded phrases first (a provider's
|
||||
error code can be a login problem and not a limit), then the built-in phrases and a learned driver's own."""
|
||||
driver = _D.driver_for(cand.get("tool")) if cand else None
|
||||
return (_D.provider_failure(cand, text) if cand else None) or classify_failure(text, returncode, _D.extra_signatures(driver))
|
||||
|
||||
|
||||
def parse_reset(text, now=None):
|
||||
"""The epoch second a limit message says the worker is back at (an ISO date-time or date, best after the
|
||||
word "reset"), or None when it names none or only a past one."""
|
||||
@@ -540,12 +547,14 @@ def mark_unavailable(worker, text, now=None):
|
||||
when the text shows only the model is. The time it is back is parsed from the message when it gives one,
|
||||
else the usual widening wait. Returns {"worker", "keys", "reason", "note", "until"} or None when the text
|
||||
is no such failure. Never a quality judgement."""
|
||||
failure = classify_failure(text)
|
||||
if failure is None or not worker:
|
||||
if not worker:
|
||||
return None
|
||||
cand = resolve_worker(worker, _cached_candidates()[0]) or {"worker": worker, "model": worker, "tool": None}
|
||||
failure = failure_for(text, cand)
|
||||
if failure is None:
|
||||
return None
|
||||
reason, note, retry = failure
|
||||
now = time.time() if now is None else now
|
||||
cand = resolve_worker(worker, _cached_candidates()[0]) or {"worker": worker, "model": worker, "tool": None}
|
||||
model = str(cand.get("model") or "")
|
||||
if _MODEL_ONLY.search(text or ""):
|
||||
keys = [cand["worker"]]
|
||||
@@ -556,7 +565,10 @@ def mark_unavailable(worker, text, now=None):
|
||||
else:
|
||||
keys = [cand["worker"]]
|
||||
until = parse_reset(text, now)
|
||||
avail = record_down(keys, reason, note, now=now, retry_after_s=None if until else retry, until_ts=until)
|
||||
if until is None and reason == "limit":
|
||||
until = _D.limit_until(cand) # the provider's own allowance probe says when it is back
|
||||
avail = record_down(keys, reason, note, now=now, retry_after_s=None if until else retry, until_ts=until,
|
||||
provider=_provider_to_mark(cand))
|
||||
shown = avail.get(str(keys[-1]).lower()) or {}
|
||||
return {"worker": cand["worker"], "keys": keys, "reason": reason, "note": note,
|
||||
"until": until if until is not None else shown.get("retry_at")}
|
||||
@@ -1121,6 +1133,15 @@ def same_model(a, b):
|
||||
return a == b or a in b or b in a
|
||||
|
||||
|
||||
def same_worker(chosen, routed, provider_named=False):
|
||||
"""Do a delegation's worker and the router's recommendation name one worker? As same_model, except that a
|
||||
model of the same name under another provider is another worker when the call names its provider."""
|
||||
if provider_named and "/" in str(routed) and "/" in str(chosen) \
|
||||
and str(chosen).split("/", 1)[0].lower() != str(routed).split("/", 1)[0].lower():
|
||||
return False
|
||||
return same_model(chosen, routed)
|
||||
|
||||
|
||||
def _own_workers(candidates, own_model):
|
||||
return [c["worker"] for c in candidates
|
||||
if own_model and any(same_model(own_model, x) for x in
|
||||
@@ -1134,12 +1155,13 @@ def recommend(kind, difficulty, cwd=None, own_model=None):
|
||||
other worker is usable."""
|
||||
records = read_records()
|
||||
candidates, _tools = _cached_candidates(records)
|
||||
_D.apply_allowances(candidates, cached_only=True) # a hook never asks a provider; the last reading stands
|
||||
candidates, _cold, _x = routable_candidates(candidates, records)
|
||||
prefs = effective_prefs(kind, difficulty, cwd or os.getcwd())
|
||||
candidates, _limited = apply_limits(candidates, prefs)
|
||||
result = routing.choose(candidates, records, read_availability(), kind, difficulty, now=time.time(),
|
||||
exclude=_own_workers(candidates, own_model), avoid=prefs["avoid"], prefer=prefs["prefer"],
|
||||
floors=route_floors())
|
||||
floors=route_floors(), explore_free_every=explore_free_every())
|
||||
choice = result["choice"]
|
||||
if choice is None:
|
||||
return None, None, 0
|
||||
@@ -1366,6 +1388,13 @@ def _down_provider(cand):
|
||||
return prov if prov and prov != str(cand.get("tool") or "").lower() else None
|
||||
|
||||
|
||||
def _provider_to_mark(cand):
|
||||
"""The provider a failure of this worker marks down: its own (a tool that carries several, or a host's), or
|
||||
the part of its model before a slash."""
|
||||
model = str(cand.get("model") or "")
|
||||
return _down_provider(cand) or (model.split("/", 1)[0] if "/" in model else None)
|
||||
|
||||
|
||||
def _down_keys(cand, reason):
|
||||
keys = [cand["worker"]]
|
||||
model = str(cand.get("model") or "")
|
||||
@@ -1452,15 +1481,14 @@ def run_delegation(candidates, kind, difficulty, prompt, cwd, explicit=None, rev
|
||||
% (cand["worker"], timeout, transcript))
|
||||
return None, None, notes
|
||||
_append_transcript(transcript, cand["worker"], cmd, out, err, rc)
|
||||
failure = (_D.provider_failure(cand, out + "\n" + err)
|
||||
or classify_failure(out + "\n" + err, rc, _D.extra_signatures(driver)))
|
||||
failure = failure_for(out + "\n" + err, cand, rc)
|
||||
if failure is not None:
|
||||
reason, note, retry = failure
|
||||
until = parse_reset(out + "\n" + err) # the time the message itself names, when it names one
|
||||
if until is None and reason == "limit":
|
||||
until = _D.limit_until(cand) # else the provider's allowance probe, when one is defined
|
||||
record_down(_down_keys(cand, reason), reason, note, retry_after_s=None if until else retry, until_ts=until,
|
||||
provider=_down_provider(cand) or (str(cand.get("model")).split("/", 1)[0] if "/" in str(cand.get("model")) else None))
|
||||
provider=_provider_to_mark(cand))
|
||||
mark_discovery_stale()
|
||||
notes.append("%s is unavailable (%s: %s); trying the next choice" % (cand["worker"], reason, note))
|
||||
cand = None
|
||||
@@ -1812,6 +1840,8 @@ def _route_retry(args, ctx, kind, difficulty, candidates, records, prefs):
|
||||
return None
|
||||
print(pick["worker"])
|
||||
print("mechanism: %s" % mechanism_for(pick))
|
||||
for line in _D.unproven_lines(pick):
|
||||
print(line)
|
||||
if res["step"] == "same":
|
||||
print(RETRY_BRIEF_LINE)
|
||||
else:
|
||||
|
||||
@@ -346,7 +346,7 @@ class ConfigDefault(SisiCase):
|
||||
for section in ("gate", "verify", "retro", "route", "unit", "orchestrate"):
|
||||
self.assertIn(section, cfg)
|
||||
self.assertEqual(sorted(cfg["orchestrate"]), ["direct_calls", "direct_chars", "enabled", "extension", "route_window_min"])
|
||||
self.assertEqual(sorted(cfg["route"]), ["price_blend_input_parts", "standing_floor"])
|
||||
self.assertEqual(sorted(cfg["route"]), ["explore_free_one_in", "price_blend_input_parts", "standing_floor"])
|
||||
self.assertEqual(cfg["unit"], {"stale_hours": 12})
|
||||
self.assertEqual(store.config()["orchestrate"]["direct_calls"], 6)
|
||||
|
||||
|
||||
Reference in new issue
Block a user