Repository navigation
Prevent agent startup from waiting on model catalog scans - #10728
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Confirmed the attach path in unsloth_cli/commands/start.py still routes through /v1/models and waits on the full catalog, and the new resident route with the 404 fallback keeps older servers working. Will get this reviewed. |
|
Confirmed the attach path in unsloth_cli/commands/start.py still routes every listing through /v1/models, so a slow local or media scan blows the 30 second deadline, and the new resident route with the 404 fallback looks like the right shape. Note #10693 is also adding authenticated residency endpoints in studio/backend/routes/inference.py, so could you check the two do not collide before I review? |
…io paths Describing residency peeks at the orchestrator instead of constructing one, so correct the two comments that still explained the thread hop by a cold singleton build; what it keeps off the loop now is the sync resolver-index work. Pin two things the resident route relies on but nothing checked. A resident GGUF carrying a variant is the common shape and takes the quant branch, which must answer from the index rather than reach the disk. And an allowlisted /api/inference path is matched by its mounted spelling, which the existing route matrix only pins for the /v1 router, so a rename there could silently strand the entry.
Name the listing helper after the route it calls, so the path, the handler and the helper read alike. _http_json and the listing call carried the same two except blocks verbatim; give them one formatter, which also lets _http_json state that it handles a failed request rather than only an HTTP error. Report one failure when nothing is serving instead of two. An empty listing and one holding only unloaded entries are the same situation to the user, and which of them arrives depends only on the server's version. The comments describing this path still described /v1/models, which it no longer calls. Point them at the listing the code actually requests. Two also claimed the listing carries no GGUF variant: it carries the quant while that reference resolves, and what it never carries is the runtime load settings.
Studio only started raising 404 for an unknown /api path when its SPA catch-all was changed to; before that the catch-all returned a plain dict, which FastAPI serialises as a 200 carrying {"error": "API endpoint not found"}. Discovery read that as a successful listing with no models, so against those servers `unsloth start` reported nothing loaded while a model was resident, and the survivor probe reported the model gone. The key check passed either way and hid it.
Accept the resident answer only when it carries a data list, and fall back to /v1/models otherwise. Keying on the listing rather than on one status code also covers a proxy that answers an unknown path some other way.
b2a3b16 to
ea17c69
Compare
|
Rebased on Fix — discovery against older servers. The fallback keyed on HTTP 404 alone, but Studio only started raising 404 for an unknown Tidying. Tests for the quant probe staying off the disk (the common resident-GGUF shape, which the existing no-scan test did not reach), for the allowlisted One thing worth knowing when reviewing: this does not help the agent's own Two test failures currently on the branch reproduce on a clean |
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The CLI now asks for /api/inference/loaded-models before falling back to /v1/models, but this file's FakeServer only answered the compat spelling and rejected the new one as an unexpected request. Accept both, so the stub covers the URL the CLI actually sends and still covers the fallback.
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
One more commit: Caught by running every test that imports the start CLI rather than just the two directories nearest the change: 757 passed; that file was the only stub hardcoding the old URL. |
Lyxot
left a comment
There was a problem hiding this comment.
Approving. The bug is real: /v1/models answers only after the full local catalog scan, so on a machine with a slow scan folder an agent asking what is resident at startup could outlast its deadline and read a loaded model as unloaded. Serving that question from a dedicated route that never constructs an orchestrator is the right shape, and the CLI falls back to /v1/models against older servers, so discovery keeps working across versions.
Validated on a staging CI run of this exact head: the studio, python and backend test jobs pass. The remaining red checks are off this change — the three Core jobs fail in unsloth_zoo, and Repo tests (CPU, rest) names only files this PR does not touch.
…thai#16831) With the "Unsloth model" read-aloud engine, Read aloud in chat can take seconds longer than Generate on the Audio page for the same text and the same loaded speech model. A user on Discord reported 10 to 20 s in chat against about half a second on the Audio page. ## Cause Before every utterance, `generateStudioTtsAudio` looks up the loaded speech model with `GET /v1/models` (`resolveReadAloudModel`, added in unslothai#14191) so it can name it in `/audio/generate`. `/v1/models` lists every downloaded model, and the scan behind it is cached for only 30 s (`_CATALOG_TTL_S`). A click more than 30 s after the last listing, which is the usual case for reading a finished reply, waits for a full rescan of the downloaded models. The Audio page never lists the catalog, so it does not pay this cost. Auto read-aloud and the Settings › Voice preview use the same function and wait the same way. ## Fix Read aloud now lists models from `GET /api/inference/loaded-models`, which unslothai#10728 added so agent startup would not wait on the same scan. Its rows are the same `_openai_model_objects` entries that `/v1/models` marks `loaded: true`, including `task` and `audio_workflows` for a speech model kept beside the chat model, so the chosen model id does not change. There are no backend changes. The "Custom endpoint" engine and system voices do not use this lookup and are unchanged. If the reporter was using "Custom endpoint", this PR does not address their delay. Not addressed: the same report says auto read-aloud does not speak a scheduled task's reply when the chat is opened. `AutoReadAloud` only speaks a reply that finishes while the chat is open, which is how it treats every chat opened from history. Speaking unread scheduled results on open would need a separate product decision. ## Verification Live on `origin/main` (`16060aba73`) with a CPU-only Studio, `gemma-4-E2B-it` Q4_K_M as the chat model and Kokoro-82M loaded beside it. I sent the request sequence the adapter sends (the listing, then `/audio/generate` naming the speech model it found), waiting 35 s before each one. Listing time: | Round | `/v1/models` (main) | `/api/inference/loaded-models` (this PR) | | --- | --- | --- | | 1 | 3.25 s | 0.02 s | | 2 | 13.16 s | 0.01 s | | 3 | 3.78 s | 0.01 s | Generation took about 9 s on both (Kokoro on the CPU). Both listings returned the same loaded rows, and every response came from Kokoro. - `read-aloud-studio-voice.test.ts` now serves the loaded-models listing, and a new test checks that read aloud never requests `/v1/models`. It fails on main. `tts-custom-connections-disabled.test.ts` mocks the new path. - 380 tests in the read-aloud, TTS and model-catalog files pass. Full frontend suite: 14943 pass and 18 fail. 17 of those also fail with main's versions of these files. The remaining one is a find-in-page timing test that passes 3 out of 3 times when run alone. - Typecheck passes. Biome and ESLint report the same findings on these files as on main. - I did not click Read aloud in a browser.
When
unsloth startattaches to a loaded model, its model-list request waits forthe full local and media catalog. If discovery exceeds the 30-second HTTP deadline,
startup fails with
Couldn't list models: timed outbefore the agent launches.Add an authenticated resident-model endpoint that reuses public model IDs and
context metadata, and use it for agent attachment, API-key checks, and survivor
checks. The metadata helper peeks at the existing orchestrator so a GGUF-only or
idle server does not initialize an unused backend. Full
/v1/modelsdiscoveryis unchanged; older servers fall back to it on HTTP 404.
Validation:
662 focused tests pass afterward, including against current upstream main.
Model-loading/status routes and keyless-off remain protected.
main, pass with the fix, and fail again when the CLI fix is reverted.
start --no-launchcommands succeed, and a completion returnsready.The injected-delay test proves the failure mechanism, not the original reporter's
exact trigger. The real-model smoke covers server attachment/configuration rather
than native Desktop or agent subprocess execution. Avoiding the catalog scan
requires an updated CLI and backend.