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:
YeonGyu-Kim
2026-04-03 16:41:59 +09:00
parent c78a9e640a
commit ed06428ba3
2 changed files with 78 additions and 1 deletions
+3 -1
View File
@@ -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 {