@@ -123,9 +123,9 @@ def _check_input_for_harmful_content(message: str) -> tuple[bool, str]:
123123 r"You are a Text Content Agent" ,
124124 r"You are an Image Content Agent" ,
125125 r"You are a Compliance Agent" ,
126- # Handoff instructions
127- r"hand off to \w+_agent " ,
128- r"hand back to \w+_agent " ,
126+ # Handoff instructions (match both underscore and hyphen agent names)
127+ r"hand off to \w+[_\-]agent " ,
128+ r"hand back to \w+[_\-]agent " ,
129129 r"may hand off to" ,
130130 r"After (?:generating|completing|validation|parsing)" ,
131131 # Internal workflow markers
@@ -142,8 +142,8 @@ def _check_input_for_harmful_content(message: str) -> tuple[bool, str]:
142142 # RAI internal instructions
143143 r"NEVER generate images that contain:" ,
144144 r"Responsible AI - Image Generation Rules" ,
145- # Agent framework references
146- r"compliance_agent|triage_agent|planning_agent|research_agent|text_content_agent|image_content_agent " ,
145+ # Agent framework references (match both underscore and hyphen separators)
146+ r"compliance[_\-]agent|triage[_\-]agent|planning[_\-]agent|research[_\-]agent|text[_\-]content[_\-]agent|image[_\-]content[_\-]agent " ,
147147]
148148
149149_SYSTEM_PROMPT_PATTERNS_COMPILED = [re .compile (pattern , re .IGNORECASE | re .DOTALL ) for pattern in SYSTEM_PROMPT_PATTERNS ]
@@ -591,9 +591,11 @@ def initialize(self) -> None:
591591 # Get the chat client
592592 chat_client = self ._get_chat_client ()
593593
594- # Agent names - Foundry workflow names require hyphens, while direct mode
595- # continues to use underscores.
596- name_sep = "-" if self ._use_foundry else "_"
594+ # Agent names - always use underscores so that instruction strings
595+ # (TRIAGE_INSTRUCTIONS, *_CONTENT_INSTRUCTIONS, etc.) and the
596+ # SYSTEM_PROMPT_PATTERNS leakage-detection regexes stay in sync.
597+ # Foundry workflows accept underscore names; no hyphen conversion needed.
598+ name_sep = "_"
597599
598600 # Create all agents
599601 # NOTE: Handoff workflow participants must set
0 commit comments