Skip to content

Plugins: chat.params hook cannot override the model (only sampling params) — model-switch plugins are forced to abort+resend, which breaks one-shot opencode run callers #49712

Description

@acaliebe

Description

Plugins: chat.params hook cannot override the model (only sampling params) — model-switch plugins are forced to abort+resend, which breaks one-shot opencode run callers

Environment

  • opencode: v1.18.31 (also observed on v1.18.30)
  • Context: plugin ecosystem, specifically model-fallback plugins (opencode-auto-fallback v0.4.59)
  • OS: Linux (Debian 13)

Summary

The chat.params plugin hook allows overriding sampling params only — temperature, topP, reasoningEffort, maxTokens, thinking — but not providerID/modelID of the upcoming request. Verified in the plugin's dist code: the hook handler maps exactly those fields onto the output; a model change is impossible from inside the hook.

Consequence: any plugin that needs to switch the model for an in-flight task (rate-limit fallback, context-overflow large-model switch, A/B routing) must abort the session and re-send a new prompt with body.model. There is no abort-free path.

Why that hurts: opencode run callers

For long-lived clients (TUI, HTTP POST /session/:id/message against a serve instance) abort+resend works: the process survives the abort, the plugin's follow-up prompt lands, the task continues on the new model.

But opencode run is a one-shot CLI: when its prompt is aborted, it prints Error: Aborted and exits — taking the plugin's in-flight follow-up prompt with it. The task is silently lost. Real-world case: a daily cron research job (opencode run -s <long-running-session> "<task>") failed 4 days in a row with Error: Aborted because the session context was over the model's threshold and the fallback plugin aborted to switch to a large-context model. Nothing executed; nothing logged on the plugin side that the continuation was lost.

Feature request

Enable plugins to change the model of the upcoming request without aborting the session, e.g.:

  1. Extend the chat.params hook so providerID/modelID (and small-model/large-model variants) can be overridden for the request being built, or
  2. Add a dedicated hook (e.g. chat.model) that runs before provider resolution and can return a model override.

This would allow abort-free model switching (fallback on rate limit, large-context switch on overflow) and fix the whole class of „scheduled task silently lost" failures. It also complements the native model-fallback discussions (#7602, stalled PR #26292): even with native fallback, plugin-level per-agent routing still needs a clean way to redirect the model.

Related

Happy to test patches and provide detailed logs from the real-world failure case.

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions