opencode 模型行为分析

环境扫描结果

配置文件

文件路径
项目配置D:\GitRepo\git.atibm.com\at\hermes-oracle-at\opencode.json
全局配置C:\Users\cat\.config\opencode\opencode.jsonc

安装状态

安装源版本状态
Scoop(主)1.16.2✅ 当前生效
WinGet(次)1.15.6❌ 已卸载
手动安装残留✅ 无
npm global 残留✅ 无

两版本共用同一套配置文件,不产生配置冲突。WinGet 已卸载,PATH 干净。

当前配置摘要

配置项来源
model未设置
small_model未设置
自定义 agent
自定义 providerv100/Qwen3.5-27B全局配置
CLI -m 参数未传

模型加载优先级(官方文档)

  1. --model / -m CLI 参数
  2. config 中的 model 字段
  3. 上次使用的模型
  4. 内置默认模型(内部优先级排序)

三个均未设置,当前走第 4 级:opencode 内置默认模型不是你定义的 v100/Qwen3.5-27B

切换模型后的隐藏行为分析

1️⃣ small_model 未设置 → 🔴 后台任务模型失控

small_model 的官方定义:"Small model to use for tasks like title generation"。

涉及的内置隐藏 agent:

隐藏 agent用途触发时机
title自动生成对话标题每次用户发消息后
summary生成对话摘要共享/存档时
compaction压缩长上下文上下文窗口满时

模型路由规则:

  • small_model 设置了 → 用 small_model
  • small_model 未设置 → 回退到主 model

你的 small_model 未设置 → 它们用了你的主模型(昂贵)而不是一个小模型。这不是"跑错模型",而是"不该用大模型的任务用了大模型",浪费 token/成本。

2️⃣ Subagent 继承规则 → 🟢 通常正确

官方文档:

"If you don't specify a model, primary agents use the globally configured model, while subagents will use the model of the primary agent that invoked them."

内置 subagent模型来源
general继承调用方的主 agent 模型
explore继承调用方的主 agent 模型
scout继承调用方的主 agent 模型

你没有自定义 agent,所以:切换主模型 → subagent 跟着走,行为正确

3️⃣ command 可独立指定模型 → 🟢 无风险

配置 schema 显示 command 可以有自己的 model 字段,但你没有定义 command,不适用。

4️⃣ agent 可独立指定模型 → 🟢 无风险

每个 agent 都可以有独立 model,但你没有为任何内置 agent 指定 model,他们都走继承链。

总结:模型失控全景

场景当前风险原因
主对话🔴 不是 Qwenmodel 未设置,走内置默认模型
title 自动标题🔴 浪费small_model 未设置,回退到主模型
summary 摘要🔴 浪费同上
compaction 压缩🔴 浪费同上
@general subagent🟢 正确继承主 agent 模型
@explore subagent🟢 正确同上
自定义 command🟢 无风险未定义
自定义 agent🟢 无风险未定义

修复建议

在全局配置 C:\Users\cat\.config\opencode\opencode.jsonc 中显式设置:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "v100/Qwen3.5-27B",
  "small_model": "v100/Qwen3.5-27B",
  "provider": {
    "v100": {
      "name": "v100",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://v1008080.atibm.com/v1"
      },
      "models": {
        "Qwen3.5-27B": {
          "name": "Qwen3.5-27B"
        }
      }
    }
  }
}