Skip to content

Commit 48ac10d

Browse files
committed
better error message for agent when spawn tool as agent
1 parent 70ac4bc commit 48ac10d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
2+
import { toolNames } from '@codebuff/common/tools/constants'
23
import { parseAgentId } from '@codebuff/common/util/agent-id-parsing'
34
import { generateCompactId } from '@codebuff/common/util/string'
45

@@ -241,6 +242,11 @@ export async function validateAndGetAgentTemplate(
241242
})
242243

243244
if (!agentTemplate) {
245+
if (toolNames.includes(agentTypeStr as any)) {
246+
throw new Error(
247+
`"${agentTypeStr}" is a tool, not an agent. Call it directly as a tool instead of wrapping it in spawn_agents.`,
248+
)
249+
}
244250
throw new Error(`Agent type ${agentTypeStr} not found.`)
245251
}
246252
const BASE_AGENTS = ['base', 'base-free', 'base-max', 'base-experimental']

0 commit comments

Comments
 (0)