fix(prompts): replace [SYSTEM: with [IMPORTANT: to avoid Azure content filter

Azure OpenAI content filters (Default/DefaultV2) treat bracketed
[SYSTEM: ...] meta-instructions as prompt-injection attempts and
reject requests with HTTP 400.

Replacing [SYSTEM: with [IMPORTANT: preserves the same semantic
meaning for the model while bypassing the Azure heuristic.

Fixes #6576
This commit is contained in:
ygd58
2026-04-09 15:10:07 +02:00
committed by Teknium
parent f2d655529a
commit d7a3468246
2 changed files with 5 additions and 5 deletions

View File

@@ -329,7 +329,7 @@ def build_skill_invocation_message(
loaded_skill, skill_dir, skill_name = loaded loaded_skill, skill_dir, skill_name = loaded
activation_note = ( activation_note = (
f'[SYSTEM: The user has invoked the "{skill_name}" skill, indicating they want ' f'[IMPORTANT: The user has invoked the "{skill_name}" skill, indicating they want '
"you to follow its instructions. The full skill content is loaded below.]" "you to follow its instructions. The full skill content is loaded below.]"
) )
return _build_skill_message( return _build_skill_message(
@@ -368,7 +368,7 @@ def build_preloaded_skills_prompt(
loaded_skill, skill_dir, skill_name = loaded loaded_skill, skill_dir, skill_name = loaded
activation_note = ( activation_note = (
f'[SYSTEM: The user launched this CLI session with the "{skill_name}" skill ' f'[IMPORTANT: The user launched this CLI session with the "{skill_name}" skill '
"preloaded. Treat its instructions as active guidance for the duration of this " "preloaded. Treat its instructions as active guidance for the duration of this "
"session unless the user overrides them.]" "session unless the user overrides them.]"
) )

View File

@@ -715,7 +715,7 @@ def _build_job_prompt(job: dict, prerun_script: Optional[tuple] = None) -> str:
# Always prepend cron execution guidance so the agent knows how # Always prepend cron execution guidance so the agent knows how
# delivery works and can suppress delivery when appropriate. # delivery works and can suppress delivery when appropriate.
cron_hint = ( cron_hint = (
"[SYSTEM: You are running as a scheduled cron job. " "[IMPORTANT: You are running as a scheduled cron job. "
"DELIVERY: Your final response will be automatically delivered " "DELIVERY: Your final response will be automatically delivered "
"to the user — do NOT use send_message or try to deliver " "to the user — do NOT use send_message or try to deliver "
"the output yourself. Just produce your report/output as your " "the output yourself. Just produce your report/output as your "
@@ -751,7 +751,7 @@ def _build_job_prompt(job: dict, prerun_script: Optional[tuple] = None) -> str:
parts.append("") parts.append("")
parts.extend( parts.extend(
[ [
f'[SYSTEM: The user has invoked the "{skill_name}" skill, indicating they want you to follow its instructions. The full skill content is loaded below.]', f'[IMPORTANT: The user has invoked the "{skill_name}" skill, indicating they want you to follow its instructions. The full skill content is loaded below.]',
"", "",
content, content,
] ]
@@ -759,7 +759,7 @@ def _build_job_prompt(job: dict, prerun_script: Optional[tuple] = None) -> str:
if skipped: if skipped:
notice = ( notice = (
f"[SYSTEM: The following skill(s) were listed for this job but could not be found " f"[IMPORTANT: The following skill(s) were listed for this job but could not be found "
f"and were skipped: {', '.join(skipped)}. " f"and were skipped: {', '.join(skipped)}. "
f"Start your response with a brief notice so the user is aware, e.g.: " f"Start your response with a brief notice so the user is aware, e.g.: "
f"'⚠️ Skill(s) not found and skipped: {', '.join(skipped)}']" f"'⚠️ Skill(s) not found and skipped: {', '.join(skipped)}']"