Skip to content

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

Closed

Description

@chipit24

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).

Activity

  1. github-actions commented on Feb 16, 2026

    @github-actions
    Contributor

    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 [FEATURE] Support default variant configuration per agent (#7156) #7138

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

  2. rekram1-node commented on Feb 16, 2026

    @rekram1-node
    Contributor

    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

  3. github-actions commented on Apr 18, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions