Merge pull request #3813 from code-yeongyu/fix/agent-name-backslash-sanitize
fix(agent): sanitize backslash/quote from agent name
This commit is contained in:
@@ -214,6 +214,10 @@ describe("stripAgentListSortPrefix", () => {
|
||||
it("strips legacy zero-width sort prefixes baked into v3.14.0–v3.16.0 sessions", () => {
|
||||
expect(stripAgentListSortPrefix("\u200B\u200BHephaestus - Deep Agent")).toBe("Hephaestus - Deep Agent")
|
||||
})
|
||||
|
||||
it("strips leading and trailing wrapper characters after sort prefix removal", () => {
|
||||
expect(stripAgentListSortPrefix("\\Hephaestus - Deep Agent\\")).toBe("Hephaestus - Deep Agent")
|
||||
})
|
||||
})
|
||||
|
||||
describe("normalizeAgentForPrompt", () => {
|
||||
|
||||
@@ -28,13 +28,14 @@ export const AGENT_DISPLAY_NAMES: Record<string, string> = {
|
||||
|
||||
const INVISIBLE_AGENT_CHARACTERS_REGEX = /[\u200B\u200C\u200D\uFEFF]/g
|
||||
const VISIBLE_AGENT_LIST_SORT_PREFIX_REGEX = /^\d+\|/
|
||||
const AGENT_WRAPPER_CHARS_REGEX = /^[\\/"']+|[\\/"']+$/g
|
||||
|
||||
export function stripInvisibleAgentCharacters(agentName: string): string {
|
||||
return agentName.replace(INVISIBLE_AGENT_CHARACTERS_REGEX, "")
|
||||
}
|
||||
|
||||
export function stripAgentListSortPrefix(agentName: string): string {
|
||||
return stripInvisibleAgentCharacters(agentName).replace(VISIBLE_AGENT_LIST_SORT_PREFIX_REGEX, "")
|
||||
return stripInvisibleAgentCharacters(agentName).replace(VISIBLE_AGENT_LIST_SORT_PREFIX_REGEX, "").replace(AGENT_WRAPPER_CHARS_REGEX, "")
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user