agents switch does not respect the custom model with id #1987

Closed
opened 2026-02-16 17:33:35 -05:00 by yindo · 8 comments
Owner

Originally created by @towry on GitHub (Oct 7, 2025).

Originally assigned to: @rekram1-node on GitHub.

I have searched the issues, and it seems the "id" feature just landed last week.

The issue is that the /agents command switches the agent, but it does not change the model specified in the "model" field of that agent, if the model is an extended custom model with an "id" field.

If you manually select the model, the model works.

Originally created by @towry on GitHub (Oct 7, 2025). Originally assigned to: @rekram1-node on GitHub. I have searched the issues, and it seems the "id" feature just landed last week. - https://github.com/sst/opencode/issues/2877 - https://github.com/sst/opencode/issues/2829 The issue is that the `/agents` command switches the agent, but it does not change the model specified in the "model" field of that agent, if the model is an extended custom model with an "id" field. If you manually select the model, the model works.
yindo closed this issue 2026-02-16 17:33:35 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 7, 2025):

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

  • #1661: Model switch automatically when changing the mode - reports similar behavior where model switching doesn't work as expected when switching modes/agents
  • #2877: Models search does not show custom models unless explicit difference is specified - deals with custom models with ID field and search/display issues (referenced in #3015 description)
  • #2829: How to add new custom model variants with extended options? - deals with creating custom model variants with extended options using ID field (also referenced in #3015 description)

The core issue appears to be that when using custom models with extended configurations (including the 'id' field), the agent switching mechanism doesn't properly handle the model selection. Issues #2877 and #2829 were already referenced in your description and deal with the same 'id' feature that landed recently.

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

@github-actions[bot] commented on GitHub (Oct 7, 2025): This issue might be a duplicate of existing issues. Please check: - #1661: Model switch automatically when changing the mode - reports similar behavior where model switching doesn't work as expected when switching modes/agents - #2877: Models search does not show custom models unless explicit difference is specified - deals with custom models with ID field and search/display issues (referenced in #3015 description) - #2829: How to add new custom model variants with extended options? - deals with creating custom model variants with extended options using ID field (also referenced in #3015 description) The core issue appears to be that when using custom models with extended configurations (including the 'id' field), the agent switching mechanism doesn't properly handle the model selection. Issues #2877 and #2829 were already referenced in your description and deal with the same 'id' feature that landed recently. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

@towry hmm can you share your agent definition? So I can see how you are referencing the model?

Perhaps your opencode.json too so I can see the model id there?

if you run:
opencode debug config

it should give me both of those

@rekram1-node commented on GitHub (Oct 7, 2025): @towry hmm can you share your agent definition? So I can see how you are referencing the model? Perhaps your opencode.json too so I can see the model id there? if you run: `opencode debug config` it should give me both of those
Author
Owner

@towry commented on GitHub (Oct 7, 2025):

{
  "$schema": "https://opencode.ai/config.json",
  "share": "disabled",
  "autoupdate": false,
  "disabled_providers": [
    "openai",
    "gemini"
  ],
  "model": "glm-4.6",
  "small_model": "glm-4.6",
  "agent": {
    "plan": {
      "model": "openrouter/gpt-5-codex-medium",
      "tools": {
        "write": false,
        "edit": false,
        "bash": false,
        "grep": true,
        "list": true,
        "glob": true,
        "exa-search*": true,
        "grep-code*": true
      },
      "mode": "primary"
    },
    "kick-muse": {
      "model": "glm-4.6",
      "prompt": "取并遵lse)",
      "tools": {
        "write": true,
        "edit": true,
        "bash": true,
        "read": true,
        "glob": true,
        "grep": true,
        "list": true,
        "patch": true,
        "todowrite": true,
        "todoread": true,
        "webfetch": true,
        "playwright*": true,
        "exa-search*": true,
        "grep-code*": true
      },
      "description": "Kick start muse workflow",
      "mode": "primary",
      "permission": {
        "edit": "allow",
        "bash": "allow",
        "webfetch": "allow"
      },
      "name": "kick-muse"
    },
    "muse": {
      "model": "openrouter/gpt-5-codex-medium",
      "prompt": "角色增步骤时复制)\n\n### [Step step-<new-id> — <名称>]\n\n<按上述结构填充>\n```",
      "tools": {
        "write": true,
        "edit": true,
        "bash": true,
        "read": true,
        "glob": true,
        "grep": true,
        "list": true,
        "webfetch": true,
        "exa-search*": true,
        "grep-code*": true
      },
      "description": "Muse",
      "mode": "primary",
      "permission": {
        "edit": "ask",
        "bash": "ask"
      },
      "name": "muse"
    },
    "sumon": {
      "model": "glm-4.6",
      "prompt": "Pleas.\n```",
      "tools": {
        "write": true,
        "edit": true,
        "bash": false,
        "read": true,
        "glob": true,
        "grep": true,
        "list": true,
        "webfetch": true
      },
      "description": "Summarize changes",
      "mode": "subagent",
      "permission": {
        "edit": "ask"
      },
      "name": "sumon"
    },
    "sage": {
      "model": "glm-4.6",
      "prompt": "作为维护。",
      "tools": {
        "write": false,
        "edit": false,
        "bash": true,
        "read": true,
        "glob": true,
        "grep": true
      },
      "description": "Research and analyze codebases",
      "mode": "subagent",
      "permission": {
        "edit": "allow",
        "bash": "allow"
      },
      "name": "sage"
    },
    "oracle": {
      "model": "openrouter/openai/gpt-5-codex",
      "prompt": "You ans.",
      "tools": {
        "write": false,
        "edit": false,
        "patch": false,
        "read": true,
        "grep": true,
        "list": true,
        "glob": true,
        "exa-search*": true,
        "grep-code*": true
      },
      "description": "\"Consult the Oracle - an AI advisor powered by OpenAI's GTP-5 reasoning model\nthat can plan, review, and provide expert guidance.\"\n",
      "mode": "subagent",
      "name": "oracle",
      "reasoningEffort": "medium",
      "reasoningSummary": "auto",
      "textVerbosity": "medium"
    },
    "designer": {
      "model": "openrouter/meta-llama/llama-4-maverick",
      "prompt": "You areents",
      "tools": {
        "write": true,
        "edit": true,
        "bash": true,
        "read": true,
        "glob": true,
        "grep": true
      },
      "description": "Designer, converts images to Figma-compatible design data in JSONC format for webpage and UI element creation, return the generated file path",
      "mode": "subagent",
      "permission": {
        "edit": "allow",
        "bash": "allow"
      },
      "name": "designer"
    }
  },
  "provider": {
    "openrouter": {
      "name": "OpenRouter",
      "npm": "@openrouter/ai-sdk-provider",
      "models": {
        "gpt-5-codex-medium": {
          "id": "openai/gpt-5-codex",
          "name": "GPT-5 Codex Medium",
          "options": {
            "reasoningEffort": "medium",
            "textVerbosity": "low",
            "reasoningSummary": "auto"
          }
        },
        "gpt-5-medium": {
          "id": "openai/gpt-5",
          "name": "GPT-5 Medium",
          "options": {
            "reasoningEffort": "medium",
            "textVerbosity": "low",
            "reasoningSummary": "auto"
          }
        },
        "z-ai/glm-4.6": {
          "name": "GLM 4.6",
          "attachment": true,
          "tool_call": true
        },
        "deepseek/deepseek-chat-v3.1": {
          "name": "DeepSeek Chat V3.1",
          "attachment": true,
          "tool_call": true
        },
        "qwen/qwen3-max": {
          "name": "Qwen 3 Max",
          "attachment": true,
          "tool_call": true
        },
        "mistralai/mistral-small-24b-instruct-2501": {
          "name": "Mistral Small 24B Instruct"
        },
        "meta-llama/llama-4-scout": {
          "name": "Llama 4 Scout",
          "attachment": true,
          "tool_call": true
        },
        "meta-llama/llama-4-maverick": {
          "name": "Llama 4 Maverick",
          "attachment": true,
          "tool_call": true
        },
        "meta-llama/llama-3.3-70b-instruct": {
          "name": "Llama 3.3 70B Instruct",
          "tool_call": true
        },
        "z-ai/glm-4.5": {
          "name": "GLM 4.5",
          "tool_call": true
        },
        "z-ai/glm-4.5v": {
          "name": "GLM 4.5V",
          "attachment": true,
          "tool_call": true
        },
        "mistralai/mistral-medium-3.1": {
          "name": "Mistral Medium 3.1",
          "attachment": false,
          "tool_call": true
        },
        "moonshotai/kimi-vl-a3b-thinking": {
          "name": "Kimi VL A3B Thinking",
          "attachment": false,
          "tool_call": true
        },
        "google/gemini-2.5-flash-lite-preview-06-17": {
          "name": "Gemini 2.5 Flash Lite",
          "attachment": true,
          "tool_call": true
        },
        "anthropic/claude-3-haiku": {
          "name": "Claude 3 Haiku",
          "tool_call": true
        },
        "google/gemini-2.0-flash-001": {
          "name": "Gemini 2.0 Flash"
        }
      },
      "options": {
        "apiKey": "xxxxxxxxxxxxxx"
      }
    }
  },
  "mcp": {
    "commander": {
      "type": "local",
      "command": [
        "commander-mcp"
      ],
      "enabled": true
    },
    "context7": {
      "type": "local",
      "command": [
        "bunx",
        "@upstash/context7-mcp"
      ],
      "environment": {},
      "enabled": true
    },
    "playwright": {
      "type": "local",
      "command": [
        "bunx",
        "@playwright/mcp@latest"
      ],
      "enabled": false
    },
    "github-mcp-server": {
      "type": "local",
      "command": [
        "github-mcp-server",
        "stdio",
        "--toolsets",
        "all"
      ],
      "environment": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "xxxxxxxxxx"
      },
      "enabled": false
    },
    "exa-search": {
      "type": "remote",
      "url": "https://mcp.exa.ai/mcp",
      "enabled": true,
      "headers": {
        "Authorization": "Bearer xxxxxxxxxx"
      }
    },
    "grep-code": {
      "type": "remote",
      "url": "https://mcp.grep.app",
      "enabled": false
    }
  },
  "lsp": {},
  "instructions": [
    "./AGENTS.md"
  ],
  "permission": {
    "edit": "allow",
    "bash": {
      "*": "ask",
      "git commit": "ask",
      "git add": "ask"
    },
    "webfetch": "ask"
  },
  "mode": {},
  "plugin": [
    "file:///Users/towry/.config/opencode/plugin/notify.ts"
  ],
  "command": {},
  "username": "towry"
}

I masked the api key and removed some content in the prompt.

@towry commented on GitHub (Oct 7, 2025): ``` { "$schema": "https://opencode.ai/config.json", "share": "disabled", "autoupdate": false, "disabled_providers": [ "openai", "gemini" ], "model": "glm-4.6", "small_model": "glm-4.6", "agent": { "plan": { "model": "openrouter/gpt-5-codex-medium", "tools": { "write": false, "edit": false, "bash": false, "grep": true, "list": true, "glob": true, "exa-search*": true, "grep-code*": true }, "mode": "primary" }, "kick-muse": { "model": "glm-4.6", "prompt": "取并遵lse)", "tools": { "write": true, "edit": true, "bash": true, "read": true, "glob": true, "grep": true, "list": true, "patch": true, "todowrite": true, "todoread": true, "webfetch": true, "playwright*": true, "exa-search*": true, "grep-code*": true }, "description": "Kick start muse workflow", "mode": "primary", "permission": { "edit": "allow", "bash": "allow", "webfetch": "allow" }, "name": "kick-muse" }, "muse": { "model": "openrouter/gpt-5-codex-medium", "prompt": "角色增步骤时复制)\n\n### [Step step-<new-id> — <名称>]\n\n<按上述结构填充>\n```", "tools": { "write": true, "edit": true, "bash": true, "read": true, "glob": true, "grep": true, "list": true, "webfetch": true, "exa-search*": true, "grep-code*": true }, "description": "Muse", "mode": "primary", "permission": { "edit": "ask", "bash": "ask" }, "name": "muse" }, "sumon": { "model": "glm-4.6", "prompt": "Pleas.\n```", "tools": { "write": true, "edit": true, "bash": false, "read": true, "glob": true, "grep": true, "list": true, "webfetch": true }, "description": "Summarize changes", "mode": "subagent", "permission": { "edit": "ask" }, "name": "sumon" }, "sage": { "model": "glm-4.6", "prompt": "作为维护。", "tools": { "write": false, "edit": false, "bash": true, "read": true, "glob": true, "grep": true }, "description": "Research and analyze codebases", "mode": "subagent", "permission": { "edit": "allow", "bash": "allow" }, "name": "sage" }, "oracle": { "model": "openrouter/openai/gpt-5-codex", "prompt": "You ans.", "tools": { "write": false, "edit": false, "patch": false, "read": true, "grep": true, "list": true, "glob": true, "exa-search*": true, "grep-code*": true }, "description": "\"Consult the Oracle - an AI advisor powered by OpenAI's GTP-5 reasoning model\nthat can plan, review, and provide expert guidance.\"\n", "mode": "subagent", "name": "oracle", "reasoningEffort": "medium", "reasoningSummary": "auto", "textVerbosity": "medium" }, "designer": { "model": "openrouter/meta-llama/llama-4-maverick", "prompt": "You areents", "tools": { "write": true, "edit": true, "bash": true, "read": true, "glob": true, "grep": true }, "description": "Designer, converts images to Figma-compatible design data in JSONC format for webpage and UI element creation, return the generated file path", "mode": "subagent", "permission": { "edit": "allow", "bash": "allow" }, "name": "designer" } }, "provider": { "openrouter": { "name": "OpenRouter", "npm": "@openrouter/ai-sdk-provider", "models": { "gpt-5-codex-medium": { "id": "openai/gpt-5-codex", "name": "GPT-5 Codex Medium", "options": { "reasoningEffort": "medium", "textVerbosity": "low", "reasoningSummary": "auto" } }, "gpt-5-medium": { "id": "openai/gpt-5", "name": "GPT-5 Medium", "options": { "reasoningEffort": "medium", "textVerbosity": "low", "reasoningSummary": "auto" } }, "z-ai/glm-4.6": { "name": "GLM 4.6", "attachment": true, "tool_call": true }, "deepseek/deepseek-chat-v3.1": { "name": "DeepSeek Chat V3.1", "attachment": true, "tool_call": true }, "qwen/qwen3-max": { "name": "Qwen 3 Max", "attachment": true, "tool_call": true }, "mistralai/mistral-small-24b-instruct-2501": { "name": "Mistral Small 24B Instruct" }, "meta-llama/llama-4-scout": { "name": "Llama 4 Scout", "attachment": true, "tool_call": true }, "meta-llama/llama-4-maverick": { "name": "Llama 4 Maverick", "attachment": true, "tool_call": true }, "meta-llama/llama-3.3-70b-instruct": { "name": "Llama 3.3 70B Instruct", "tool_call": true }, "z-ai/glm-4.5": { "name": "GLM 4.5", "tool_call": true }, "z-ai/glm-4.5v": { "name": "GLM 4.5V", "attachment": true, "tool_call": true }, "mistralai/mistral-medium-3.1": { "name": "Mistral Medium 3.1", "attachment": false, "tool_call": true }, "moonshotai/kimi-vl-a3b-thinking": { "name": "Kimi VL A3B Thinking", "attachment": false, "tool_call": true }, "google/gemini-2.5-flash-lite-preview-06-17": { "name": "Gemini 2.5 Flash Lite", "attachment": true, "tool_call": true }, "anthropic/claude-3-haiku": { "name": "Claude 3 Haiku", "tool_call": true }, "google/gemini-2.0-flash-001": { "name": "Gemini 2.0 Flash" } }, "options": { "apiKey": "xxxxxxxxxxxxxx" } } }, "mcp": { "commander": { "type": "local", "command": [ "commander-mcp" ], "enabled": true }, "context7": { "type": "local", "command": [ "bunx", "@upstash/context7-mcp" ], "environment": {}, "enabled": true }, "playwright": { "type": "local", "command": [ "bunx", "@playwright/mcp@latest" ], "enabled": false }, "github-mcp-server": { "type": "local", "command": [ "github-mcp-server", "stdio", "--toolsets", "all" ], "environment": { "GITHUB_PERSONAL_ACCESS_TOKEN": "xxxxxxxxxx" }, "enabled": false }, "exa-search": { "type": "remote", "url": "https://mcp.exa.ai/mcp", "enabled": true, "headers": { "Authorization": "Bearer xxxxxxxxxx" } }, "grep-code": { "type": "remote", "url": "https://mcp.grep.app", "enabled": false } }, "lsp": {}, "instructions": [ "./AGENTS.md" ], "permission": { "edit": "allow", "bash": { "*": "ask", "git commit": "ask", "git add": "ask" }, "webfetch": "ask" }, "mode": {}, "plugin": [ "file:///Users/towry/.config/opencode/plugin/notify.ts" ], "command": {}, "username": "towry" } ``` I masked the api key and removed some content in the prompt.
Author
Owner

@towry commented on GitHub (Oct 7, 2025):

https://github.com/user-attachments/assets/c771ea6a-474a-450d-88e1-d78a5b541409

If i change the model of "plan" agent to model without id, the "tab" or "/agents" switch works.

@towry commented on GitHub (Oct 7, 2025): https://github.com/user-attachments/assets/c771ea6a-474a-450d-88e1-d78a5b541409 If i change the model of "plan" agent to model without id, the "tab" or "/agents" switch works.
Author
Owner

@towry commented on GitHub (Oct 7, 2025):

/.config/opencodedirenv 🔽/😤
➜  opencode models | grep codex                                                                                                                         00:17:59
openrouter/openai/gpt-5-codex
openrouter/gpt-5-codex-medium
@towry commented on GitHub (Oct 7, 2025): ``` /.config/opencodedirenv 🔽/😤 ➜ opencode models | grep codex 00:17:59 openrouter/openai/gpt-5-codex openrouter/gpt-5-codex-medium ```
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

ah ik issue then. will need to think about solution

@rekram1-node commented on GitHub (Oct 7, 2025): ah ik issue then. will need to think about solution
Author
Owner

@rekram1-node commented on GitHub (Oct 13, 2025):

will be fixed in next release

@rekram1-node commented on GitHub (Oct 13, 2025): will be fixed in next release
Author
Owner

@towry commented on GitHub (Oct 14, 2025):

Working great!

@towry commented on GitHub (Oct 14, 2025): Working great!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1987