Skip to content

fix(server): stop waiting for plugins in the model, provider, generate, voice and websearch handlers - #63814

Open
rekram1-node wants to merge 1 commit into
devfrom
drop-policy-waits
Open

rekram1-node wants to merge 1 commit into
devfrom
drop-policy-waits

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Issue for this PR

Reverts #63040. Helps #63130.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

#63040 put a 5 s wait for plugins (503 after it) back on model.list, model.default, provider.list, generate.*, voice.* and websearch.query, because managed policy and the Console config apply after providers register, so a denied provider or free model could be listed or used while a Location activates. In the #core thread that gap was accepted (blocking the Console plugin on its fetch is fine, a brief free-models flash is fine, MDM is the real lockdown), so this goes back to #62796: no handler waits.

before: GET /api/model on a Location still loading → wait up to 5 s → 503
after:  GET /api/model → whatever is loaded now; *.updated fills the rest

The cost of the waits is real: a slow Location, like 2000 linked skills in #63130, returns 503 from /api/model on every request, and the desktop app no longer retries 503s since #62830, so its model picker stays empty until loading ends.

The video generation start added since (#64140) used the same wait and drops it too. The mobile apps no longer depend on the wait: the fixes shipped in Android v0.8.0 and iOS v0.507.0.

AGENTS.md drops the temporary exception, and the provider test goes back to checking that catalog reads answer while a plugin is still loading.

How did you verify your code works?

  • packages/server (132) and packages/cli (408) tests with an isolated HOME, bun run check, and typecheck:tsc in packages/server.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #63130, #63273, #61359

Public API: model/provider/generate (incl. video.create)/voice/websearch endpoints no longer return 503 while plugins load (no schema change)

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend merging this change: it is an exact revert of #63040. All seven changed files match their versions just before it, so the handlers are back to the #62796 behaviour.

I ran opencode serve from source in a project with a local plugin whose setup takes 7 s. On the base, GET /api/model returned 503 Location plugins did not finish activating after about 5.2 s. With this PR it returned 200 in about 0.1 s with the current (empty) list, and the full catalog once loading finished. The updated provider.test.ts passes here and fails on the base. The packages/server tests (127 pass) and typecheck:tsc pass. In the TUI, base and PR look the same 30 s into a cold start, so there are no screenshots.

Public API: nothing in the schema changes (SDK, client, OpenAPI). At runtime, model.list, model.default, provider.list, generate.*, voice.* and websearch.query no longer return 503 ServiceUnavailableError (service: "plugin") after 5 s. They now answer straight away with what is loaded, possibly an empty or partial list. Callers that relied on the wait need to wait themselves or refresh on *.updated, which the TUI, client data layer and ACP already do.

No concerns.

Related: #63130, #63273, #61359

@amr-karam

Copy link
Copy Markdown

Windows results for #63814, with a plain-dev control on the same machine (both from source, three runs each):

operation dev (wait present) #63814 (wait removed)
api model.list --standalone 503 ×3 (11.72s / 12.32s / 13.41s) OK ×3 (7.41s / 5.83s / 6.53s)
api session.list --standalone OK ×3 (5.11s / 6.11s / 5.92s) OK ×3 (5.49s / 4.73s / 5.92s)

Answers carry 0 model / session ids, which matches the design note in AGENTS.md ("lists may be empty or partial on a cold Location"). No 503 anywhere on #63814, and the successful calls come back several seconds sooner than the failing control.

On your session.list question: it does not fail here — and the control shows it does not fail on plain dev either on this machine, so the gap you suspected is not present on current dev for session.list. For the record, session.list --standalone did 503 on my installed 2.2.7 months of behavior ago; something on dev since then already stopped it waiting, which is consistent with the direction of this PR.

Two notes for anyone reproducing from source:

  • The entry point matters. bun packages/cli/src/index.ts ... from the repo root fails with Cannot find module 'react/jsx-dev-runtime' (the TUI tsconfig sets jsxImportSource: @opentui/solid, which only resolves through the CLI package's tsconfig chain). The documented root script works: bun run --cwd packages/cli src/index.ts api model.list --standalone. That may be what blocked --standalone from source in your environment.
  • From source, failures take 12-13s versus ~9s from the installed 2.2.7 binary — cold activation is slower here from source, which is exactly the case this PR removes.

Separately, still open and not covered by this PR: a Session.StepFailedError: Nothing to compact yet I hit on the running background service (2.2.7) on a large session. Different signature from the plugin-wait 503 — it fires when compaction runs with nothing left to reduce. Happy to file it as its own issue with logs if useful.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend merging this change: it is still sound after the rebase. The only new change is that generate.video.create (from #64140) no longer waits for plugins either. It is still blocked first when the video_generate flag is off, and a video model that hasn't loaded yet now fails with not-found, as AGENTS.md describes. Nothing in packages/server/src waits for plugins any more.

I re-ran serve from source with a plugin whose setup takes 7 s. On the base, /api/model returned 503 after about 5 s. With this PR it returned 200 straight away with the current (empty) list. The packages/server tests (132 pass, including the video-generation tests) and typecheck:tsc pass.

Public API: the same as before, with generate.video.create added to the list. These endpoints no longer return 503 ServiceUnavailableError (service: "plugin") while plugins load, and nothing in the schema changes.

No new concerns.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants