Ask AI (OpenCode 2): "Timeout waiting for server to start" — AI provider uses the v1-era @opencode-ai/sdk, incompatible with OpenCode ≥ 2.0
Summary
On plannotator 0.28.19 with OpenCode v2.0.29, clicking Ask AI fails every time with Timeout waiting for server to start after 5000ms. The spawned server is healthy — the readiness detection is what fails.
Root cause
Ask AI's OpenCode provider is built on @opencode-ai/[email protected] — the v1-era SDK. Its createOpencodeServer() spawns opencode serve and resolves only when a stdout line starts with opencode server listening. OpenCode ≥ 2.0 prints server listening on http://… (prefix dropped), so the promise never resolves and the 5s timeout kills the working server (~1s startup, verified locally).
For OpenCode 2 the correct packages are @opencode/sdk / @opencode/client (v2.0.29), which avoid stdout parsing entirely — the SDK hosts the router in-process, and the client discovers an existing service via the XDG registration file.
Impact
As far as I can tell, this affects every OpenCode ≥ 2.0 user, deterministically, on every Ask AI use.
Suggested fixes
- Migrate the Ask AI provider to
@opencode/sdk/@opencode/clientv2 — this also makes reusing an already-runningopencodeservice the default behavior via the registration-file discovery (the review flows already reuse the local server, #567 / #513). - Stopgap if a full migration is heavy: patch the vendored provider's matcher to accept both log lines, or poll HTTP readiness. Note the legacy package line is at its end (1.19.0), so this buys time only.
Environment
plannotator 0.28.19, OpenCode 2.0.29, macOS.
Related issues
- #1413 — Ask AI on OpenCode 2, but a post-start SSE failure ("Failed to fetch"), not this spawn-timeout
- #567 / #513 — precedent for reusing an existing local server
- #1194 — OpenCode 2 adapter context
Update after #2449: with plannotator 0.28.67 and 0.29.0 against OpenCode 2.3.0 and 2.3.2, Ask AI with the OpenCode provider now gets past server startup (the readiness-line fix works), but fails later in createSession() with OpenCode did not return session data.
Verified locally by probing the spawned opencode serve directly:
POST /session(the v1-era route the bundled@opencode-ai/[email protected]still calls viaclient.session.create()) → 405. It is not an API route on OpenCode ≥ 2.0: GET on the same path returns the web SPA HTML, POST returns 405, and the server logshttp.url=/session http.status=405.POST /api/session(HTTP Basic auth,opencode:<password>) → 201, returns the session JSON.
So the readiness fix uncovered the second half of the incompatibility: the provider's requests never reach the v2 API, which lives under /api/. Notably, plannotator's own Inbox launch path already calls POST /api/session directly — Ask AI could do the same, or the vendored SDK patch could point session.create at the v2 path.
Workaround for anyone hitting this: pick a non-OpenCode provider in the Ask AI "To:" menu.
Follow-up: we built a working local compatibility shim, which turned the "suggested fix" into a precise migration checklist. The v1→v2 incompatibilities are not just the route prefix — there are five layers:
- Route prefix + auth: v2 serves the API under
/api/and requires HTTP Basic auth (opencode:<password>), not Bearer. - Bodyless POSTs: the v1 SDK sends POSTs with
Content-Type: application/jsonbut an empty body (session.create); v2 answers400 InvalidRequestError: Expected object. Needs a{}body. - Response envelope: v2 wraps successful JSON responses in
{data: ...}; the v1 SDK'sresult.datamust BE the object. Without unwrapping,session.create"succeeds" withid: undefinedand the next call goes out as the literal path/session/{id}/prompt_async→ 404 (this is what surfaces as "OpenCode did not return session data." in one variant and "OpenCode rejected prompt: HTTP 404" in another). prompt_asyncis gone: v2 replaced it withPOST /session/{id}/prompttaking{text, system?, model?: {providerID, modelID}}instead of{parts: [...], model: "provider/id", system}.- SSE event names changed:
message.part.delta→session.text.delta({sessionID, delta}), terminalsession.status {status:{type:"idle"}}→session.execution.succeeded, plussession.text.ended,session.execution.failed, etc.
Our shim (an opencode PATH wrapper that spawns the real opencode serve, then reverse-proxies with the translations above) makes Ask AI on OpenCode 2.3.2 work end-to-end — streaming text included. Happy to share the ~200-line prototype if useful.
So the real fix in plannotator is a provider migration to the v2 SDK/client rather than a patched vendored SDK.
Verified: the fix works end-to-end. On plannotator 0.29.4 against OpenCode 2.4.1, Ask AI with the OpenCode provider answers normally — streaming included — with no local workaround. Thanks @JasonOA888 for the clean transport detection (the /api/info gate saved us from caring about which CLI is installed). One small observation from the verification run: a permission reply POST got a 404 against 2.4.1 without breaking the answer — possibly API drift worth a look if permission flows matter for Ask AI.