Add a new plugin hook named chat.model that runs before an LLM call and can replace the active { providerID, modelID }.
Today plugins can modify params, headers, prompts, and tool behavior, but they cannot choose a different model at call time. That makes it hard to build plugin-driven routing patterns that feel like a good fit for OpenCode: cost-based switching, fallback to another model, per-tool routing, and review workflows that use multiple configured models without manually changing the session model.
I think this hook should stay minimal. It only needs the current call context: sessionID, agent, current model, provider context, current message, and step. It should return an optional replacement model and does not need full conversation history.
This seems related to fallback discussions like #7602, but broader: the goal is to expose model routing to plugins, not only add native fallback behavior. Since this changes core plugin infrastructure, I think it should start as a design discussion before implementation.
Add a new plugin hook named
chat.modelthat runs before an LLM call and can replace the active{ providerID, modelID }.Today plugins can modify params, headers, prompts, and tool behavior, but they cannot choose a different model at call time. That makes it hard to build plugin-driven routing patterns that feel like a good fit for OpenCode: cost-based switching, fallback to another model, per-tool routing, and review workflows that use multiple configured models without manually changing the session model.
I think this hook should stay minimal. It only needs the current call context:
sessionID,agent, current model, provider context, current message, andstep. It should return an optional replacement model and does not need full conversation history.This seems related to fallback discussions like #7602, but broader: the goal is to expose model routing to plugins, not only add native fallback behavior. Since this changes core plugin infrastructure, I think it should start as a design discussion before implementation.