Calling use_skill tool switches agent to default_agent unexpectedly #6585

Closed
opened 2026-02-16 18:04:40 -05:00 by yindo · 2 comments
Owner

Originally created by @fancydirty on GitHub (Jan 17, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Problem
When any agent calls the use_skill tool, it gets reset to the global model setting instead of keeping the agent's own configured model.

Evidence
Before use_skill:
▣ Orchestrator · claude-opus-4-5-thinking-high
After use_skill:
▣ Orchestrator · gemini-3-flash
Impact

  • Agents lose their model configuration after loading skills
  • Subagents spawned in parallel get stuck when their model changes mid-task
  • Skills become unusable for agents with custom model configurations
    Expected Behavior
    use_skill should load the skill content without changing the agent's model. Each agent should retain its configured model throughout its lifecycle.

Plugins

oh-my-opencode, oh-my-opencode-slim

OpenCode version

1.1.25

Steps to reproduce

  1. Configure global model: "google/gemini-3-flash" in opencode.json
  2. Configure an agent with a different model:
    orchestrator: {
    model: anthropic/claude-opus-4-5
    }
  3. Use that agent and call use_skill("some-skill")
  4. Observed: Agent switches to global default model (gemini-3-flash)
  5. Expected: Agent stays on its configured model (claude-opus-4-5)

Operating System

Ubuntu 22.04

Terminal

wsl

Originally created by @fancydirty on GitHub (Jan 17, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Problem When any agent calls the use_skill tool, it gets reset to the global model setting instead of keeping the agent's own configured model. Evidence Before use_skill: ▣ Orchestrator · claude-opus-4-5-thinking-high After use_skill: ▣ Orchestrator · gemini-3-flash Impact - Agents lose their model configuration after loading skills - Subagents spawned in parallel get stuck when their model changes mid-task - Skills become unusable for agents with custom model configurations Expected Behavior use_skill should load the skill content without changing the agent's model. Each agent should retain its configured model throughout its lifecycle. ### Plugins oh-my-opencode, oh-my-opencode-slim ### OpenCode version 1.1.25 ### Steps to reproduce 1. Configure global model: "google/gemini-3-flash" in opencode.json 2. Configure an agent with a different model: orchestrator: { model: anthropic/claude-opus-4-5 } 3. Use that agent and call use_skill("some-skill") 4. Observed: Agent switches to global default model (gemini-3-flash) 5. Expected: Agent stays on its configured model (claude-opus-4-5) 6. ### Operating System Ubuntu 22.04 ### Terminal wsl
yindo added the bug label 2026-02-16 18:04:40 -05:00
yindo closed this issue 2026-02-16 18:04:40 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 17, 2026):

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

  • #7099: Server API ignores agent's configured model when only agent parameter is passed
  • #6636: Subagent with specific model results in model change in build and plan mode
  • #6928: Subtask commands do not inherit model

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 17, 2026): This issue might be a duplicate of existing issues. Please check: - #7099: Server API ignores agent's configured model when only agent parameter is passed - #6636: Subagent with specific model results in model change in build and plan mode - #6928: Subtask commands do not inherit model Feel free to ignore if none of these address your specific case.
Author
Owner

@fancydirty commented on GitHub (Jan 19, 2026):

修复方案

这个问题的根本原因是在 use_skill 工具调用 client.session.prompt() 时没有传递 agent 参数,导致 OpenCode 使用默认的 agent 配置。

问题代码

superpowers.jsuse_skill 工具中:

await client.session.prompt({
  path: { id: context.sessionID },
  body: { noReply: true, parts: [{ type: 'text', text: skillContent, synthetic: true }] }
});

修复后代码

添加 agent: context.agent 参数来保留当前 agent 的配置:

await client.session.prompt({
  path: { id: context.sessionID },
  body: { agent: context.agent, noReply: true, parts: [{ type: 'text', text: skillContent, synthetic: true }] }
});

修改文件位置

文件路径: ~/.config/opencode/plugin/superpowers.js(或项目内的 .opencode/plugin/superpowers.js

代码行: 约第 120 行附近

修复原理

context.agent 包含了当前会话的 agent 配置信息。当调用 session.prompt() 时传递这个参数,OpenCode 会使用当前的 agent 设置而不是全局默认配置。

验证步骤

  1. 重启 OpenCode 使插件重新加载
  2. 配置一个非默认模型的 agent
  3. 调用 use_skill("some-skill")
  4. 确认 agent 模型保持不变

相关参考

这个修复确保 use_skill 加载 skill 内容时不会改变 agent 的模型配置。

@fancydirty commented on GitHub (Jan 19, 2026): ## 修复方案 这个问题的根本原因是在 `use_skill` 工具调用 `client.session.prompt()` 时没有传递 `agent` 参数,导致 OpenCode 使用默认的 agent 配置。 ### 问题代码 在 `superpowers.js` 的 `use_skill` 工具中: ```javascript await client.session.prompt({ path: { id: context.sessionID }, body: { noReply: true, parts: [{ type: 'text', text: skillContent, synthetic: true }] } }); ``` ### 修复后代码 添加 `agent: context.agent` 参数来保留当前 agent 的配置: ```javascript await client.session.prompt({ path: { id: context.sessionID }, body: { agent: context.agent, noReply: true, parts: [{ type: 'text', text: skillContent, synthetic: true }] } }); ``` ### 修改文件位置 **文件路径**: `~/.config/opencode/plugin/superpowers.js`(或项目内的 `.opencode/plugin/superpowers.js`) **代码行**: 约第 120 行附近 ### 修复原理 `context.agent` 包含了当前会话的 agent 配置信息。当调用 `session.prompt()` 时传递这个参数,OpenCode 会使用当前的 agent 设置而不是全局默认配置。 ### 验证步骤 1. 重启 OpenCode 使插件重新加载 2. 配置一个非默认模型的 agent 3. 调用 `use_skill("some-skill")` 4. 确认 agent 模型保持不变 ### 相关参考 - 相同的修复已应用于 `obra/superpowers` 仓库的 PR #290: https://github.com/obra/superpowers/pull/290 这个修复确保 `use_skill` 加载 skill 内容时不会改变 agent 的模型配置。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6585