Skip to content

[FEATURE]: plugin hook for dynamic model routing based on prompt complexity #18844

Closed as not planned

Description

@rjmorales13

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Every prompt sent through OpenCode uses the same model, whether it's "hello" or a complex multi-file refactor. There's no way to match model cost to prompt complexity. A developer on Claude ($15/1M tokens) spending 200 simple prompts/day wastes $50-60/month on prompts a free model handles perfectly.

Proposed Solution
Add a chat.model plugin hook that fires before each prompt, allowing plugins to dynamically route messages to different models based on content analysis.

This enables:

  1. De-escalation: Route simple tasks ("hello", "list files") to free/cheap models
  2. Escalation (opt-in): Route complex tasks to premium models
  3. Subagent inheritance: Subtasks inherit the routed model
  4. Per-prompt override: Users can force their selected model with !premium

Maybe suggested before but not totally sure:
Found it. There are existing issues that match:

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Mar 23, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 23, 2026
  3. github-actions commented on Mar 23, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    (Note: you've already identified these yourself in the issue body. Consider closing this issue in favor of one of the above.)

  4. assigned and unassigned on Apr 26, 2026
  5. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. JGuck commented on Jun 3, 2026

    @JGuck

    I opened #30457 with a minimal implementation of the chat.model hook.

    This should unblock the core plugin-routing part of this request: plugins can now choose a different { providerID, modelID } before an LLM call, which makes prompt-complexity routing possible.

  7. github-actions commented on Aug 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

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