Skip to content

opencode agent list does not load the agents from plugins #14036

Closed

Description

@kvokka

Description

The agents from the plugins are not loaded, while the agents from the plugin are present in TUI/WEB

TL;DR

The issue is well illustrated at RunMaestro/Maestro#284 (comment)

Plugins

oh-my-opencode@3.7.2

OpenCode version

1.2.6

Steps to reproduce

❯ opencode agent list | grep primary
build (primary)
compaction (primary)
plan (primary)
summary (primary)
title (primary)

Screenshot and/or share link

No response

Operating System

ubuntu 24.04

Terminal

iTerm

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 17, 2026
  2. code-yeongyu commented on Apr 13, 2026

    @code-yeongyu
    Contributor

    Additional Technical Detail

    After deeper analysis, I've identified the exact root cause:

    File: packages/opencode/src/agent/agent.ts lines 401-406

    export const defaultLayer = layer.pipe(
      Layer.provide(Provider.defaultLayer),
      Layer.provide(Auth.defaultLayer),
      Layer.provide(Config.defaultLayer),
      Layer.provide(Skill.defaultLayer),
    )

    Problem: Agent.defaultLayer does NOT include Plugin.layer as a dependency.

    When Agent.list() is called, it initializes state via config.get() BEFORE plugins have loaded. This means the plugin's config hook never has a chance to inject agents.

    Contrast with Provider module (provider.ts lines 1077-1080):

    // load plugins first so config() hook runs before reading cfg.provider
    const plugins = yield* plugin.list()
    // now read config providers - includes any modifications from plugin config() hook

    The Provider module correctly ensures plugins are loaded first. The Agent module should follow the same pattern.

    Suggested Fix:

    export const defaultLayer = layer.pipe(
      Layer.provide(Plugin.layer),  // ADD THIS
      Layer.provide(Provider.defaultLayer),
      Layer.provide(Auth.defaultLayer),
      Layer.provide(Config.defaultLayer),
      Layer.provide(Skill.defaultLayer),
    )

    Or alternatively, inside Agent.state, call plugin.list() before reading config, similar to how Provider.state does it.

  3. johnnyWangJingJing commented on Apr 17, 2026

    @johnnyWangJingJing

    更多技术细节

    经过深入分析,我已经找到了确切的根本原因:

    文件:packages/opencode/src/agent/agent.ts第 401-406 行

    export const defaultLayer = layer.pipe(
    Layer.provide(Provider.defaultLayer),
    Layer.provide(Auth.defaultLayer),
    Layer.provide(Config.defaultLayer),
    Layer.provide(Skill.defaultLayer),
    )
    问题:Agent.defaultLayer未将其Plugin.layer作为依赖项包含。

    调用此函数时,它会在插件加载之前Agent.list()初始化状态。这意味着插件的钩子函数根本没有机会注入代理。config.get()``config

    与提供者模块(provider.ts第 1077-1080 行)对比:

    // load plugins first so config() hook runs before reading cfg.provider
    const plugins = yield* plugin.list()
    // now read config providers - includes any modifications from plugin config() hook
    Provider 模块确保插件优先加载。Agent 模块也应遵循相同的模式。

    建议的解决方法:

    export const defaultLayer = layer.pipe(
    Layer.provide(Plugin.layer), // ADD THIS
    Layer.provide(Provider.defaultLayer),
    Layer.provide(Auth.defaultLayer),
    Layer.provide(Config.defaultLayer),
    Layer.provide(Skill.defaultLayer),
    )
    或者,也可以在内部Agent.state,在读取配置之前调用plugin.list(),类似于它是如何Provider.state做的。
    ----------------------------------->
    Excuse me, sir/madam. Could you please tell me how to fix the bugs and modify the code? Is it done manually? Was it accomplished through AI tools?

  4. kvokka commented on Apr 28, 2026

    @kvokka
    Author

    @rekram1-node The issue is still in place, and it blocks agent selection in the ACP connection of opencode with other agents like Maestro or OpenCLAW. I just can not pick the agent from the plugin. Also, this makes the global --pure redundant.

    If you don't mind, I can take a look at this one for the proper solution.

    Asking before writing any code to avoid a waste of your or my time

  5. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions