Error when trying to use custom primary agent (TypeError: undefined is not an object (evaluating 'agent.variant')) #9439

Open
opened 2026-02-16 18:12:27 -05:00 by yindo · 2 comments
Owner

Originally created by @chipit24 on GitHub (Feb 15, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

I set up a primary agent according to the docs at https://opencode.ai/docs/agents, in my global OpenCode config at ~/.config/opencode/opencode.json:

{
  "agent": {
    "build-guarded": {
      "description": "Build-like primary agent that asks before any file edits.",
      "mode": "primary",
      "name": "Build (guarded)",
      "permission": {
        "edit": "ask",
        "plan_enter": "allow",
        "question": "allow"
      }
    }
  },
  /* rest of the config ... */
}

When I select this agent and try to prompt it, I always get this error:
Image

TypeError: undefined is not an object (evaluating 'agent.variant')
      at createUserM

I tried adding both model and variant properties but I still got the exact same error, but I shouldn't have to specify this anyway as the docs mention:

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

Plugins

None

OpenCode version

1.2.5

Steps to reproduce

  1. Configure OpenCode with a custom primary agent (as mentioned in my description).
  2. Launch OpenCode.
  3. Press Tab to select your agent.
  4. Enter any message, submit it.
  5. See error.

Screenshot and/or share link

I'm unable to share a link to the session, but this is the error:
Image

Operating System

macOS 26.2

Terminal

Happens in every terminal I've tried (Warp, iTerm 2, Ghostty, and WebStorm's integrated terminal).

Originally created by @chipit24 on GitHub (Feb 15, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description I set up a primary agent according to the docs at https://opencode.ai/docs/agents, in my global OpenCode config at `~/.config/opencode/opencode.json`: ```json { "agent": { "build-guarded": { "description": "Build-like primary agent that asks before any file edits.", "mode": "primary", "name": "Build (guarded)", "permission": { "edit": "ask", "plan_enter": "allow", "question": "allow" } } }, /* rest of the config ... */ } ``` When I select this agent and try to prompt it, I always get this error: <img width="553" height="184" alt="Image" src="https://github.com/user-attachments/assets/13154530-c121-4de4-893d-309fb6991b89" /> ```console TypeError: undefined is not an object (evaluating 'agent.variant') at createUserM ``` I tried adding both `model` and `variant` properties but I still got the exact same error, but I shouldn't have to specify this anyway as the docs mention: > If you don’t specify a model, primary agents use the [model globally configured](https://opencode.ai/docs/config#models) while subagents will use the model of the primary agent that invoked the subagent. ### Plugins None ### OpenCode version 1.2.5 ### Steps to reproduce 1. Configure OpenCode with a custom primary agent (as mentioned in my description). 2. Launch OpenCode. 3. Press Tab to select your agent. 4. Enter any message, submit it. 5. See error. ### Screenshot and/or share link I'm unable to share a link to the session, but this is the error: <img width="866" height="569" alt="Image" src="https://github.com/user-attachments/assets/92b25f6e-34e3-491a-82ba-9d2505469624" /> ### Operating System macOS 26.2 ### Terminal Happens in every terminal I've tried (Warp, iTerm 2, Ghostty, and WebStorm's integrated terminal).
yindo added the bug label 2026-02-16 18:12:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 15, 2026):

This issue appears to be related to #7138, which requests support for default variant configuration per agent. The error you're encountering suggests that the agent.variant field may not be fully implemented or recognized in your version.

Please verify:

  1. That you're using the latest version of OpenCode (you have v1.2.5)
  2. Check the release notes to see if variant configuration support has been added since your version
  3. Consider following the implementation progress on #7138

If you continue to experience this issue after updating, please provide any additional error context or logs.

@github-actions[bot] commented on GitHub (Feb 15, 2026): This issue appears to be related to #7138, which requests support for default variant configuration per agent. The error you're encountering suggests that the `agent.variant` field may not be fully implemented or recognized in your version. Please verify: 1. That you're using the latest version of OpenCode (you have v1.2.5) 2. Check the release notes to see if variant configuration support has been added since your version 3. Consider following the implementation progress on #7138 If you continue to experience this issue after updating, please provide any additional error context or logs.
Author
Owner

@rekram1-node commented on GitHub (Feb 15, 2026):

It's because these dont match:

  "name": "Build (guarded)",
"build-guarded": {

Ofc it is a bug but just letting u know so u can have work around for now

@rekram1-node commented on GitHub (Feb 15, 2026): It's because these dont match: > "name": "Build (guarded)", > "build-guarded": { Ofc it is a bug but just letting u know so u can have work around for now
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9439