[PR #2790] feat: Add session initialize plugin event and ability to override model in chat.params #10442

Closed
opened 2026-02-16 18:15:05 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/2790

State: closed
Merged: No


This pull request introduces enhancements to the plugin hook system and refactors session initialization and model parameter handling in the SessionPrompt namespace. The changes streamline how model and provider information are passed to plugins, allow plugins to dynamically update model selection, and add a new initialization hook for chat sessions.

Plugin hook system improvements

  • Added a new chat.session plugin hook, which is triggered when a new session is initialized, providing session, model, and provider information to plugins. (packages/plugin/src/index.ts)
  • Updated the chat.params plugin hook to allow plugins to override the selected model and provider by including modelID and providerID in the output parameters. (packages/plugin/src/index.ts)

Session initialization and model parameter handling

  • Refactored session initialization in SessionPrompt to trigger the new chat.session hook when a session is first created, passing model and provider details to plugins. (packages/opencode/src/session/prompt.ts)
  • Changed the model parameter resolution flow: after invoking the chat.params hook, the code checks for plugin-supplied model and provider overrides and updates the model accordingly. (packages/opencode/src/session/prompt.ts)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/2790 **State:** closed **Merged:** No --- This pull request introduces enhancements to the plugin hook system and refactors session initialization and model parameter handling in the `SessionPrompt` namespace. The changes streamline how model and provider information are passed to plugins, allow plugins to dynamically update model selection, and add a new initialization hook for chat sessions. ### Plugin hook system improvements * Added a new `chat.session` plugin hook, which is triggered when a new session is initialized, providing session, model, and provider information to plugins. (`packages/plugin/src/index.ts`) * Updated the `chat.params` plugin hook to allow plugins to override the selected model and provider by including `modelID` and `providerID` in the output parameters. (`packages/plugin/src/index.ts`) ### Session initialization and model parameter handling * Refactored session initialization in `SessionPrompt` to trigger the new `chat.session` hook when a session is first created, passing model and provider details to plugins. (`packages/opencode/src/session/prompt.ts`) * Changed the model parameter resolution flow: after invoking the `chat.params` hook, the code checks for plugin-supplied model and provider overrides and updates the model accordingly. (`packages/opencode/src/session/prompt.ts`)
yindo added the pull-request label 2026-02-16 18:15:05 -05:00
yindo closed this issue 2026-02-16 18:15:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10442