fix(delegate-task): pass registered agent model explicitly for subagent_type (#1225)

When delegate_task uses subagent_type, extract the matched agent's model
object and pass it explicitly to session.prompt/manager.launch. This
ensures the model is always in the correct object format regardless of
how OpenCode handles string→object conversion for plugin-registered
agents.

Closes #1225
This commit is contained in:
YeonGyu-Kim
2026-01-29 11:27:07 +09:00
committed by GitHub
parent 99d22926a9
commit 35759df04e
2 changed files with 195 additions and 1 deletions
+9 -1
View File
@@ -784,7 +784,7 @@ Create the work plan directly - that's your job as the planning agent.`
// Uses case-insensitive matching to allow "Oracle", "oracle", "ORACLE" etc.
try {
const agentsResult = await client.app.agents()
type AgentInfo = { name: string; mode?: "subagent" | "primary" | "all" }
type AgentInfo = { name: string; mode?: "subagent" | "primary" | "all"; model?: { providerID: string; modelID: string } }
const agents = (agentsResult as { data?: AgentInfo[] }).data ?? agentsResult as unknown as AgentInfo[]
const callableAgents = agents.filter((a) => a.mode !== "primary")
@@ -807,6 +807,14 @@ Create the work plan directly - that's your job as the planning agent.`
}
// Use the canonical agent name from registration
agentToUse = matchedAgent.name
// Extract registered agent's model to pass explicitly to session.prompt.
// This ensures the model is always in the correct object format ({providerID, modelID})
// regardless of how OpenCode handles string→object conversion for plugin-registered agents.
// See: https://github.com/code-yeongyu/oh-my-opencode/issues/1225
if (matchedAgent.model) {
categoryModel = matchedAgent.model
}
} catch {
// If we can't fetch agents, proceed anyway - the session.prompt will fail with a clearer error
}