Skip to content

feat(core): add session model.select hook for per-step model routing - #50965

Closed
dmouse wants to merge 6 commits into
anomalyco:devfrom
dmouse:session-mode-select
Closed

dmouse wants to merge 6 commits into
anomalyco:devfrom
dmouse:session-mode-select

Conversation

@dmouse

@dmouse dmouse commented Sep 23, 2026 •

Copy link
Copy Markdown

Issue for this PR

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a model.select hook what lets plugins dynamically select the model before each provider turn, instead of using one model for the entire task. This enables routing simpler steps to cheaper models while reserving more capable models for complex work

How did you verify your code works?

I tested locally and added a test.

Screenshots / recordings

Not necessary

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@dmouse dmouse mentioned this pull request Sep 23, 2026
3 of 6 tasks
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@miguelenes

Copy link
Copy Markdown

This hook appears to provide the missing pre-resolution seam for the Jev router in this task. One additional contract matters for prompt-based routing: pick the model for a newly admitted user turn, retain that choice for the turn's tool continuations/retries/compaction recovery, and resolve a queued user turn independently when it begins. The current step field may provide that boundary, but a test should establish its behavior when prompts queue during a tool wait and when a request retries.

There is also a feedback requirement: plugins need the effective per-turn model reflected in the TUI and desktop while preserving the user's persistent session default. Since this PR intentionally leaves the Session's selected model unchanged, could the PR document how clients observe the effective model for each response, or add that signal if it is not already available?

A regression test with prompt A -> tool call -> queued prompt B would help: A's continuation must use A's selected model, then B must independently select its own model. Retrying/compaction should retain A's model. This request is specifically to preserve one choice per user prompt; automatic re-selection on each continuation would change the intended Jev routing behavior.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants