Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

feat(opencode): allow changing model mid-session

未关闭
#143 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
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
派生
134
平均合并
7 小时 40 分钟
30 天内合并 PR
29

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rivet-dev/agents 的其他 Issue

查看 rivet-dev/agents 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。