summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLekë Dobruna <[email protected]>2026-01-01 18:39:21 +0100
committerGitHub <[email protected]>2026-01-01 11:39:21 -0600
commit3b033245783899adefe2a42157e4e34cf8fb1234 (patch)
treee0705fc04faed09fe77045da607c565ad99e2da4
parent35fff0ca702faf9ede6bb1cfa4a431fdf7f710ff (diff)
downloadopencode-3b033245783899adefe2a42157e4e34cf8fb1234.tar.gz
opencode-3b033245783899adefe2a42157e4e34cf8fb1234.zip
fix: display error if invalid agent is used in a command (#6578)
-rw-r--r--packages/opencode/src/session/prompt.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 6bf71ef36..80779f468 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -1331,7 +1331,7 @@ export namespace SessionPrompt {
}
if (command.agent) {
const cmdAgent = await Agent.get(command.agent)
- if (cmdAgent.model) {
+ if (cmdAgent?.model) {
return cmdAgent.model
}
}
@@ -1353,6 +1353,16 @@ export namespace SessionPrompt {
throw e
}
const agent = await Agent.get(agentName)
+ if (!agent) {
+ const available = await Agent.list().then((agents) => agents.filter((a) => !a.hidden).map((a) => a.name))
+ const hint = available.length ? ` Available agents: ${available.join(", ")}` : ""
+ const error = new NamedError.Unknown({ message: `Agent not found: "${agentName}".${hint}` })
+ Bus.publish(Session.Event.Error, {
+ sessionID: input.sessionID,
+ error: error.toObject(),
+ })
+ throw error
+ }
const parts =
(agent.mode === "subagent" && command.subtask !== false) || command.subtask === true