-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Description
remapAgentKeysToDisplayNames() replaces original agent keys (e.g. "prometheus") with display names (e.g. "Prometheus (Plan Builder)"), but does not retain the original key. Upstream opencode's Agent.get(name) performs a direct dictionary lookup using the original internal key, which no longer exists in the agent map → returns undefined → crashes at agent.name.
Error
TypeError: undefined is not an object (evaluating 'agent.name')
at createUserMessage (src/session/prompt.ts:960:14)
Environment
- opencode-ai: v1.2.6 (also reproduced on v1.1.65)
- oh-my-opencode: v3.7.1 (also reproduced on v3.3.2, though v3.3.2 doesn't have
remapAgentKeysToDisplayNames— it has a different root cause) - OS: Linux (Ubuntu)
- oh-my-opencode loaded as plugin (not as main binary)
Root Cause
In remapAgentKeysToDisplayNames():
function remapAgentKeysToDisplayNames(agents) {
const result = {};
for (const [key, value] of Object.entries(agents)) {
const displayName = AGENT_DISPLAY_NAMES[key];
if (displayName && displayName !== key) {
result[displayName] = value; // ← only display name kept, original key dropped
} else {
result[key] = value;
}
}
return result;
}After this function runs, config.agent contains keys like "Prometheus (Plan Builder)" but not "prometheus". When a user selects Prometheus mode, upstream opencode calls Agent.get("prometheus") which does a simple x["prometheus"] lookup → undefined → crash.
Debug Evidence
Injected console.error at key points confirmed:
- ✅ Plugin IS imported
- ✅
OhMyOpenCodePlugin()IS called and returns successfully - ✅
configHandlerIS called - ✅ Agent keys after config hook:
["Sisyphus (Ultraworker)", "Hephaestus (Deep Agent)", "Prometheus (Plan Builder)", "Atlas (Plan Executor)", "Sisyphus-Junior", "oracle", ...] - ❌
"prometheus" in agentResult→ false - ✅
"Prometheus (Plan Builder)" in agentResult→ true
Fix
Retain original keys alongside display names:
function remapAgentKeysToDisplayNames(agents) {
const result = {};
for (const [key, value] of Object.entries(agents)) {
const displayName = AGENT_DISPLAY_NAMES[key];
if (displayName && displayName !== key) {
result[displayName] = value;
result[key] = value; // ← also keep original key
} else {
result[key] = value;
}
}
return result;
}Related Issues
- oh-my-opencode agents not appearing in
opencode agent listfor OpenCode 1.1.44 #1320 (oh-my-opencode agents not appearing — same symptom, previously fixed but regressed) - [Bug]: Sisyphus-Junior agent not registered - category delegation fails completely #1697 (Sisyphus-Junior agent not registered)
- Upstream opencode #8119, #10969, #8929 (same crash pattern)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels