From 708b9ce9ffd312cf594286bab82b7edf7ba8f093 Mon Sep 17 00:00:00 2001 From: "youming.tang" Date: Tue, 10 Feb 2026 14:37:23 +0900 Subject: [PATCH] fix(runtime-fallback): sort agent names by length to fix hyphenated agent detection The \b word boundary regex treats '-' as a boundary, causing 'sisyphus-junior-session-123' to incorrectly match 'sisyphus' instead of 'sisyphus-junior'. Sorting agent names by length (descending) ensures longer names are matched first, fixing the hyphenated agent detection issue. Fixes cubic-dev-ai review issue #8 --- src/hooks/runtime-fallback/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hooks/runtime-fallback/index.ts b/src/hooks/runtime-fallback/index.ts index 8c07e67d..89e0b0cc 100644 --- a/src/hooks/runtime-fallback/index.ts +++ b/src/hooks/runtime-fallback/index.ts @@ -131,7 +131,10 @@ function getFallbackModelsForSession( "multimodal-looker", ] const agentPattern = new RegExp( - `(?:^|[^a-zA-Z0-9_-])(${AGENT_NAMES.map((a) => a.replace(/-/g, "\\-")).join("|")})(?:$|[^a-zA-Z0-9_-])`, + `(?:^|[^a-zA-Z0-9_-])(${AGENT_NAMES + .sort((a, b) => b.length - a.length) + .map((a) => a.replace(/-/g, "\\-")) + .join("|")})(?:$|[^a-zA-Z0-9_-])`, "i", ) const sessionAgentMatch = sessionID.match(agentPattern)