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
- Fresh install OpenCode 1.14.41
- Install
@cortexkit/opencode-magic-context@latest
- Open any file/project to trigger the
session.created -> runHistorianPrompt flow
- 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
- Short-term: Document the minimum required OpenCode version that supports agent registration via
config hook, and provide the workaround above.
- 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).
Environment
Description
The
@cortexkit/opencode-magic-contextplugin fails to register its hidden subagents (historian,historian-editor,dreamer,sidekick) through the pluginconfighook, causing all subagent dispatches to fail with:Root Cause
The plugin registers agents in its
confighook atdist/index.js:174059-174064:However, OpenCode 1.14.41 does not propagate the
agentfield set/modified by pluginconfighooks into the agent registry. When the plugin later tries to dispatch a child session viaclient.session.prompt({ agent: 'historian', ... }),SessionPrompt.resolveToolsthrows because"historian"is not a registered agent.Steps to Reproduce
@cortexkit/opencode-magic-context@latestsession.created->runHistorianPromptflowdreamerorsidekickExpected Behavior
The
confighook’s mutation ofconfig2.agentshould 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
confighook, and provide the workaround above.confighook is not honoured by the host OpenCode version).