generate/text returns 404 "Model not found" on cold boot before plugins load
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 55/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript
Direção de pesquisa
Start with server.generate and compare its model-resolution path with SessionGenerate.generate, which already waits for Plugin.awaitActivation. Verify the change in the @opencode/Generate paths as well if the fix is placed at that layer. Done means a cold or freshly booted base-config location waits for plugin activation before resolving the model, so a valid authenticated model returns a generation response rather than 404 Model not found.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
TL;DR
Calling POST /api/experimental/generate/text (or its deprecated alias POST /api/experimental/generate) after OpenCode's base-config location has been evicted — or on a fresh server — intermittently fails with 404 Model not found even for valid, authenticated models.
The handler boots the location and tries to resolve the model ~1 ms later, while PluginSupervisor is still loading opencode.models.dev in a background fiber (~400 ms later). Unlike session endpoints, server.generate never awaits Plugin.awaitActivation.
Environment
- OpenCode:
2.4.1running asopencode serve --service - OS: macOS (Apple Silicon)
- Triggering client: Hex (
3.5.2), which callsPOST /api/experimental/generatefor dictation post-processing (any client calling/api/experimental/generate/textor/api/experimental/generateafter idle eviction hits this) - Model tested:
opencode-go/claude-haiku-5-5(credential active in DB;opencode modelslists it;opencode run -m opencode-go/claude-haiku-5-5succeeds)
What happens
- A long-running
opencode serve --servicedaemon caches loaded location services (plugins, providers, models) with an idle TTL and evicts them when unused. - When a stateless request hits
POST /api/experimental/generate(or/api/experimental/generate/text) after that base-config location was evicted:- OpenCode boots the location (
location services booted). PluginSupervisor.activateis forked into the background with a100 msdebounce to load plugins — including the built-inopencode.models.devplugin that populates providers and models.server.generatedoes not wait forPlugin.awaitActivation. It immediately queries the model snapshot ~1 ms after boot, sees an empty/incomplete catalog, and returns404 Model not found.
- OpenCode boots the location (
- ~400–500 ms after the
404was already returned,opencode.models.devfinishes loading and emitsprovider.updatedandmodel.updated. - Because that failed request warmed up the location, the very next request a few seconds or minutes later succeeds — until the location goes idle, gets evicted again, and the next request fails again.
Log evidence
Every single 404 in ~/.local/share/opencode/log/opencode.log (18 occurrences over 4 days) follows the exact same millisecond sequence:
# Base-config location was previously evicted after idle timeout:
2026-11-28T16:02:48.083Z level=INFO run=5b4fd86e message="watcher stopped" path=~/.config/oc-v1/opencode type=directory
# Next POST /api/experimental/generate arrives -> boots location -> immediately 404s (1 ms later):
2026-11-28T16:38:23.501Z level=INFO run=5b4fd86e message="location services booted" directory=~/.config/oc-v1/opencode durationMs=31
2026-11-28T16:38:23.502Z level=INFO run=5b4fd86e message="Sent HTTP response" http.method=POST http.url=/api/experimental/generate http.status=404
# Built-in plugins finish loading ~425 ms AFTER the 404 was already sent:
2026-11-28T16:38:23.926Z level=INFO run=5b4fd86e message=event event.type=provider.updated event.location.directory=~/.config/oc-v1/opencode
2026-11-28T16:38:23.932Z level=INFO run=5b4fd86e message=event event.type=model.updated event.location.directory=~/.config/oc-v1/opencode
(Successful 200 responses don't appear in opencode.log because the response middleware suppresses status < 400, but subsequent requests succeed once the location is warm — e.g. failing at 14:54:42Z and succeeding at 14:58:35Z without any restart.)
Root cause in OpenCode (2.4.1)
server.generatehandlesgenerate.text(/api/experimental/generate/text),generate.textLegacy(/api/experimental/generate),generate.image,generate.decisions, andgenerate.video.createusing the base-config location.- Session-based paths (
SessionRunner,SessionGenerate.generate,SessionPrompt.prepare,SessionCommand.execute,SessionShell.start,LocationWatcher.reconcile) all wait onPlugin.awaitActivation. server.generateand@opencode/Generate(Generate.text/image/decisions/video) do not callPlugin.awaitActivationbefore resolving the model viaModelResolver/@opencode/Model.- While
/api/modelexplicitly documents"The snapshot may precede initial plugin settlement",/api/experimental/generate/textis a generation endpoint that rejects requests with404 ModelNotFoundErrorif plugins haven't settled yet.
Suggested fix
Await Plugin.awaitActivation inside server.generate (or inside @opencode/Generate before calling ModelResolver.resolve*) when booting/using the base-config location, matching what SessionGenerate.generate already does.
- Linguagem predominante
- TypeScript
- Estrelas
- 230k
- Forks
- 31.3k
- Merge médio
- 5h 32min
- PRs com merge (30d)
- 453
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de anomalyco/opencode
-
area/desktop platform/macos status/repro-plausible type/bug version/v2
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
anomalyco/opencode#67064 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 Meio dia Facilidade para iniciantes 82/100
anomalyco/opencode#67009 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
area/web type/feature version/v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
anomalyco/opencode#67001 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
skills: a Claude-compatible SKILL.md that fails to parse is dropped without any logTalvez já em andamento @liwenjie200543 assumiu há 2 dias. Abertaarea/plugins platform/linux reproduced type/bug version/v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
anomalyco/opencode#66970 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaksTalvez já em andamento @argszero assumiu há 2 dias. Abertaarea/tui platform/wsl status/repro-simulated type/bug version/v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
anomalyco/opencode#66773 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de anomalyco/opencode
Issues semelhantes
-
enhancement feature/signals self-driving team/self-driving
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
PostHog/posthog#144208 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue web
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
triage: not actionable
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
oxc-project/oxc#30518 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug Claude useability
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
wazuh/wazuh-dashboard-plugins#9751 ·
Mantenedores costumam responder em até 1 dia