fix(delegate-task): strip wrapping chars from subagent_type before lookup
LLMs sometimes wrap agent names in backslashes, quotes, or slashes (e.g. \hephaestus\ instead of hephaestus). The trim() call only removed whitespace, causing "Agent not found" errors during delegation. Now strips leading/trailing backslashes, quotes, and slashes before the case-insensitive agent lookup. Adds regression tests for backslash-wrapped, double-quoted, and single-quoted agent names. Fixes: release blocker — delegate_task to hephaestus failing in pre-publish review sessions.
This commit is contained in:
@@ -27,7 +27,9 @@ export async function resolveSubagentExecution(
|
||||
return { agentToUse: "", categoryModel: undefined, error: `Agent name cannot be empty.` }
|
||||
}
|
||||
|
||||
const agentName = args.subagent_type.trim()
|
||||
// Strip wrapping characters (backslashes, quotes) that LLMs sometimes add around agent names
|
||||
// e.g. \hephaestus\ -> hephaestus, "oracle" -> oracle, 'explore' -> explore
|
||||
const agentName = args.subagent_type.trim().replace(/^[\\\/"']+|[\\\/"']+$/g, "").trim()
|
||||
|
||||
if (agentName.toLowerCase() === SISYPHUS_JUNIOR_AGENT.toLowerCase()) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user