Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

feat(opencode): allow changing model mid-session

オープン
#143 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust
領域
ai, api, backend

調査の方向性

Start in opencode_compat.rs, especially resolve_session_agent(), set_session_overrides(), and the runtime update path shown in the issue. Trace how SessionMessageRequest.model is resolved and how the backing agent process is managed; done means a mid-session model change updates the runtime, handles unsupported native switching, and exposes the change to the frontend.

索引モデルが issue の本文から書いたものです。

説明

Problem

When an OpenCode session is created and the first message is sent, the agent/provider/model is locked into the session runtime context. Subsequent messages cannot change the provider or model because the runtime is only set on the first message:

state.opencode.update_runtime(session_id, |runtime| {
    if runtime.session_agent_id.is_none() {
        runtime.session_agent_id = Some(agent);
        runtime.session_provider_id = Some(provider_id);
        runtime.session_model_id = Some(model_id);
    }
});

While SessionMessageRequest accepts a model field on every message, the resolved model from the first message is reused for all subsequent messages. The set_session_overrides() function can update the SessionState, but the OpenCode runtime context does not reflect the change.

This means users cannot switch models mid-conversation (e.g., start with a fast model for simple tasks, then switch to a more capable model for complex reasoning).

Expected Behavior

Users should be able to change the model on any message within an existing session. When a model field is provided in SessionMessageRequest, it should override the session-level model for that message and update the session runtime accordingly.

Proposed Approach

  1. In resolve_session_agent() (opencode_compat.rs), update the runtime even when session_agent_id is already set, if the incoming message specifies a different model.
  2. When the model changes mid-session, terminate the existing backing agent process and start a new one with the updated model, or pass the model switch through to agents that support it natively.
  3. Emit a synthetic event (e.g., session.model_changed) so the frontend can reflect the model switch.
  4. Consider whether changing the agent (not just the model within the same agent) mid-session should also be supported, or scoped out for now.

Considerations

  • Some agents may not support model switching natively — the daemon may need to restart the backing process.
  • The PATCH /opencode/session/{sessionID} endpoint could also be extended to accept model changes, giving the frontend an explicit way to switch before sending the next message.
  • Need to decide how model changes interact with conversation history — the new model should still receive the full conversation context.
主要言語
TypeScript
スター
1.6k
フォーク
131
平均マージ
7時間 40分
マージ済み PR(30日)
29

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rivet-dev/agents のほかの issue

rivet-dev/agents の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。