mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-30 05:45:35 +01:00
omniroute: a reasoning model's empty probe answer is a working login
Some checks are pending
kuhy_credit drift / drift (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
omniroute_offload pre-commit / pre-commit (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
Some checks are pending
kuhy_credit drift / drift (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
omniroute_offload pre-commit / pre-commit (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
kilo-auto/free spent the 20-token probe on reasoning and answered no text, so a kilo-gateway signed in again stayed out of free-best. The probe gets 300 tokens, and a 200 with no text counts as answering.
This commit is contained in:
parent
8e25d330f6
commit
6b8fea7960
@ -69,6 +69,9 @@ def alive(cfg: Config) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
EMPTY = "empty completion" # a 200 with no text: a reasoning model out of max_tokens, or a bad answer
|
||||
|
||||
|
||||
def chat(cfg: Config, key: str, model: str = COMBO, max_tokens: int = 300) -> str:
|
||||
"""One real completion through the combo (or one model); its text, or ApiError."""
|
||||
reply = call(
|
||||
@ -87,8 +90,7 @@ def chat(cfg: Config, key: str, model: str = COMBO, max_tokens: int = 300) -> st
|
||||
msg = f"unexpected reply: {str(reply)[:200]}"
|
||||
raise ApiError(msg) from err
|
||||
if not text:
|
||||
msg = "empty completion"
|
||||
raise ApiError(msg)
|
||||
raise ApiError(EMPTY)
|
||||
return text
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,9 @@ MIN_CONTEXT = 32_000
|
||||
DEAD = frozenset({"expired", "unauthorized"})
|
||||
# state_dir file of logins seen dead; one stays out until a real request answers
|
||||
DEAD_FILE = "dead_logins.json"
|
||||
PROBE_TOKENS = 20
|
||||
# Room for a reasoning model's thinking before its text: kilo-auto/free spent all of 20 on reasoning and
|
||||
# answered no text, so a working login read as still dead (2026-11-29 15:02).
|
||||
PROBE_TOKENS = 300
|
||||
|
||||
|
||||
def _logged_out(conn: dict[str, Any]) -> bool:
|
||||
@ -98,6 +100,8 @@ def _answers(cfg: Config, model: str) -> bool:
|
||||
try:
|
||||
api.chat(cfg, health.secret(cfg, "api_key"), model, PROBE_TOKENS)
|
||||
except (api.ApiError, OSError) as err:
|
||||
if str(err) == api.EMPTY: # it answered 200: the login works, only the text ran out of room
|
||||
return True
|
||||
print(f"still out: {model}: {err}", file=sys.stderr)
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -298,6 +298,34 @@ def test_keep_live_takes_a_dead_login_back_once_a_real_request_answers(
|
||||
assert combo._remembered(cfg) == {}
|
||||
|
||||
|
||||
def test_keep_live_takes_back_a_login_whose_reasoning_model_answers_no_text(
|
||||
cfg: gwc.Config,
|
||||
admins: list[FakeAdmin],
|
||||
notices: list[str],
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""kilo-auto/free spent the probe's tokens on reasoning: a 200 with no text is a working login."""
|
||||
_write(cfg, HEADER + "nv/a\tyes\t1.0\t128000\nkilo/auto\tyes\t1.0\t128000\n")
|
||||
(cfg.conf_dir / "api_key").write_text("k\n")
|
||||
CONNS.extend([_conn("nv"), _conn("kilo", "expired")])
|
||||
CURRENT.extend(["nv/a", "kilo/auto"])
|
||||
assert combo.keep_live(cfg) is True
|
||||
CURRENT[:] = ["nv/a"]
|
||||
CONNS[1] = _conn("kilo") # kuhy signed it in from the board
|
||||
asked: list[int] = []
|
||||
|
||||
def empty(_cfg: gwc.Config, _key: str, _model: str = api.COMBO, max_tokens: int = 0) -> str:
|
||||
asked.append(max_tokens)
|
||||
raise api.ApiError(api.EMPTY)
|
||||
|
||||
monkeypatch.setattr(api, "chat", empty)
|
||||
assert combo.keep_live(cfg) is True
|
||||
assert admins[-1].upserts == [(api.COMBO, ["nv/a", "kilo/auto"])]
|
||||
assert combo._remembered(cfg) == {}
|
||||
assert asked == [combo.PROBE_TOKENS]
|
||||
assert combo.PROBE_TOKENS >= 200
|
||||
|
||||
|
||||
def test_keep_live_does_nothing_while_an_update_holds_the_lock(
|
||||
cfg: gwc.Config, admins: list[FakeAdmin]
|
||||
) -> None:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user