Skip to content

API doesn't report invalid model errors via event stream #8460

Closed

Description

@surma

Description

API doesn't report invalid model errors via event stream

Bug

When sending a message via the API with an invalid provider/model ID, no error is surfaced to the client. The session silently goes from busy to idle with no indication that anything went wrong.

Reproduction

  1. Start opencode server
  2. Listen to events: curl http://localhost:4096/event
  3. Send a message with an invalid provider:
    curl -X POST http://localhost:4096/session/{sessionID}/message \
      -H "Content-Type: application/json" \
      -d '{"model": {"providerID": "invalid", "modelID": "some-model"}, "parts": [{"type": "text", "text": "hello"}]}'
  4. Observe: HTTP 200, session goes busy → idle, no session.error event

Expected

A session.error event should be published with a message like "Model not found: invalid/some-model. Did you mean: ...?"

Cause

Provider.getModel() is called inside loop() after the HTTP response has already started streaming. The error is thrown but never converted to a session.error event.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. ColeMurray commented on Feb 9, 2026

    @ColeMurray

    dupe of #12738

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions