Skip to content

[Bug] Hidden agents not registered: Agent not found: "historian" on OpenCode 1.14.41 #62

@HaleTom

Description

@HaleTom

Environment

  • OpenCode Version: 1.14.41
  • Plugin Version: 0.15.7 (latest)
  • Platform: Linux

Description

The @cortexkit/opencode-magic-context plugin fails to register its hidden subagents (historian, historian-editor, dreamer, sidekick) through the plugin config hook, causing all subagent dispatches to fail with:

Agent not found: "historian". Available agents: build, explore, general, plan

Root Cause

The plugin registers agents in its config hook at dist/index.js:174059-174064:

config2.agent = {
  ...config2.agent ?? {},
  [DREAMER_AGENT]: buildHiddenAgentConfig(DREAMER_AGENT, ...),
  [HISTORIAN_AGENT]: buildHiddenAgentConfig(HISTORIAN_AGENT, ...),
  [HISTORIAN_EDITOR_AGENT]: buildHiddenAgentConfig(HISTORIAN_EDITOR_AGENT, ...),
  [SIDEKICK_AGENT]: buildHiddenAgentConfig(SIDEKICK_AGENT, ...)
};

However, OpenCode 1.14.41 does not propagate the agent field set/modified by plugin config hooks into the agent registry. When the plugin later tries to dispatch a child session via client.session.prompt({ agent: 'historian', ... }), SessionPrompt.resolveTools throws because "historian" is not a registered agent.

Steps to Reproduce

  1. Fresh install OpenCode 1.14.41
  2. Install @cortexkit/opencode-magic-context@latest
  3. Open any file/project to trigger the session.created -> runHistorianPrompt flow
  4. The error surface in:
    • Magic Context compaction when context hits the threshold
    • Background dream/discovery tasks dispatching dreamer or sidekick
    • Historian recovery on session load

Expected Behavior

The config hook’s mutation of config2.agent should be respected by OpenCode, or the plugin should use a supported mechanism to register agents that is compatible with OpenCode 1.14.x.

Workaround

Manually register the hidden agents in opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "agent": {
    "historian": { "mode": "subagent", "hidden": true },
    "historian-editor": { "mode": "subagent", "hidden": true },
    "dreamer": { "mode": "subagent", "hidden": true },
    "sidekick": { "mode": "subagent", "hidden": true }
  }
}

Suggested Fix

  1. Short-term: Document the minimum required OpenCode version that supports agent registration via config hook, and provide the workaround above.
  2. Long-term: Update the plugin to register hidden agents through a supported mechanism (e.g., via the OpenCode SDK agent registration API if available, or by emitting a warning if the config hook is not honoured by the host OpenCode version).

Metadata

Metadata

Assignees

No one assigned

    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