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
This commit is contained in:
parent
d9072b4a98
commit
708b9ce9ff
@ -131,7 +131,10 @@ function getFallbackModelsForSession(
|
|||||||
"multimodal-looker",
|
"multimodal-looker",
|
||||||
]
|
]
|
||||||
const agentPattern = new RegExp(
|
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",
|
"i",
|
||||||
)
|
)
|
||||||
const sessionAgentMatch = sessionID.match(agentPattern)
|
const sessionAgentMatch = sessionID.match(agentPattern)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user