From 20cb706e034e551a6df8f6f3ff798888ee5793e7 Mon Sep 17 00:00:00 2001 From: Teknium Date: Sun, 26 Apr 2026 08:39:12 -0700 Subject: [PATCH] =?UTF-8?q?chore:=20extend=20[SYSTEM:=E2=86=92[IMPORTANT:?= =?UTF-8?q?=20rename=20+=20AUTHOR=5FMAP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #6616 covering the remaining user-injected prompt markers that the original PR did not touch (reporter's second comment on #6576 explicitly flagged these). Azure OpenAI Default/DefaultV2 content filters treat any bracketed [SYSTEM: ...] as prompt-injection and reject with HTTP 400. Remaining call sites renamed: - cli.py: background-process notifications (watch_disabled, watch_match, completion), MCP reload notice (4 live + 1 docstring) - gateway/run.py: same notification paths + auto-loaded skill banner + MCP reload notice (5 live + 1 docstring) - tools/process_registry.py: comment reference Not renamed: - environments/hermes_base_env.py '[SYSTEM]\n{content}' — RL training trajectory rendering only, never sent to Azure, part of a symmetric [USER]/[ASSISTANT]/[TOOL] scheme. AUTHOR_MAP: buraysandro9@gmail.com -> ygd58. --- cli.py | 10 +++++----- gateway/run.py | 12 ++++++------ scripts/release.py | 1 + tools/process_registry.py | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cli.py b/cli.py index da401e5c1..8ec767e94 100644 --- a/cli.py +++ b/cli.py @@ -1378,7 +1378,7 @@ def _resolve_attachment_path(raw_path: str) -> Path | None: def _format_process_notification(evt: dict) -> "str | None": - """Format a process notification event into a [SYSTEM: ...] message. + """Format a process notification event into a [IMPORTANT: ...] message. Handles both completion events (notify_on_complete) and watch pattern match events from the unified completion_queue. @@ -1388,14 +1388,14 @@ def _format_process_notification(evt: dict) -> "str | None": _cmd = evt.get("command", "unknown") if evt_type == "watch_disabled": - return f"[SYSTEM: {evt.get('message', '')}]" + return f"[IMPORTANT: {evt.get('message', '')}]" if evt_type == "watch_match": _pat = evt.get("pattern", "?") _out = evt.get("output", "") _sup = evt.get("suppressed", 0) text = ( - f"[SYSTEM: Background process {_sid} matched " + f"[IMPORTANT: Background process {_sid} matched " f"watch pattern \"{_pat}\".\n" f"Command: {_cmd}\n" f"Matched output:\n{_out}" @@ -1409,7 +1409,7 @@ def _format_process_notification(evt: dict) -> "str | None": _exit = evt.get("exit_code", "?") _out = evt.get("output", "") return ( - f"[SYSTEM: Background process {_sid} completed " + f"[IMPORTANT: Background process {_sid} completed " f"(exit code {_exit}).\n" f"Command: {_cmd}\n" f"Output:\n{_out}]" @@ -7217,7 +7217,7 @@ class HermesCLI: change_detail = ". ".join(change_parts) + ". " if change_parts else "" self.conversation_history.append({ "role": "user", - "content": f"[SYSTEM: MCP servers have been reloaded. {change_detail}{tool_summary}. The tool list for this conversation has been updated accordingly.]", + "content": f"[IMPORTANT: MCP servers have been reloaded. {change_detail}{tool_summary}. The tool list for this conversation has been updated accordingly.]", }) # Persist session immediately so the session log reflects the diff --git a/gateway/run.py b/gateway/run.py index 9926920b8..a371beb76 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -591,20 +591,20 @@ def _parse_session_key(session_key: str) -> "dict | None": def _format_gateway_process_notification(evt: dict) -> "str | None": - """Format a watch pattern event from completion_queue into a [SYSTEM:] message.""" + """Format a watch pattern event from completion_queue into a [IMPORTANT:] message.""" evt_type = evt.get("type", "completion") _sid = evt.get("session_id", "unknown") _cmd = evt.get("command", "unknown") if evt_type == "watch_disabled": - return f"[SYSTEM: {evt.get('message', '')}]" + return f"[IMPORTANT: {evt.get('message', '')}]" if evt_type == "watch_match": _pat = evt.get("pattern", "?") _out = evt.get("output", "") _sup = evt.get("suppressed", 0) text = ( - f"[SYSTEM: Background process {_sid} matched " + f"[IMPORTANT: Background process {_sid} matched " f"watch pattern \"{_pat}\".\n" f"Command: {_cmd}\n" f"Matched output:\n{_out}" @@ -4232,7 +4232,7 @@ class GatewayRunner: if _loaded: _loaded_skill, _skill_dir, _display_name = _loaded _note = ( - f'[SYSTEM: The "{_display_name}" skill is auto-loaded. ' + f'[IMPORTANT: The "{_display_name}" skill is auto-loaded. ' f"Follow its instructions for this session.]" ) _part = _build_skill_message(_loaded_skill, _skill_dir, _note) @@ -7473,7 +7473,7 @@ class GatewayRunner: change_detail = ". ".join(change_parts) + ". " if change_parts else "" reload_msg = { "role": "user", - "content": f"[SYSTEM: MCP servers have been reloaded. {change_detail}{tool_summary}. The tool list for this conversation has been updated accordingly.]", + "content": f"[IMPORTANT: MCP servers have been reloaded. {change_detail}{tool_summary}. The tool list for this conversation has been updated accordingly.]", } try: session_entry = self.session_store.get_or_create_session(event.source) @@ -8412,7 +8412,7 @@ class GatewayRunner: from tools.ansi_strip import strip_ansi _out = strip_ansi(session.output_buffer[-2000:]) if session.output_buffer else "" synth_text = ( - f"[SYSTEM: Background process {session_id} completed " + f"[IMPORTANT: Background process {session_id} completed " f"(exit code {session.exit_code}).\n" f"Command: {session.command}\n" f"Output:\n{_out}]" diff --git a/scripts/release.py b/scripts/release.py index d6d9be6d9..eb52e942d 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -119,6 +119,7 @@ AUTHOR_MAP = { "nocoo@users.noreply.github.com": "nocoo", "30841158+n-WN@users.noreply.github.com": "n-WN", "tsuijinglei@gmail.com": "hiddenpuppy", + "buraysandro9@gmail.com": "ygd58", "jerome@clawwork.ai": "HiddenPuppy", "jerome.benoit@sap.com": "jerome-benoit", "wysie@users.noreply.github.com": "Wysie", diff --git a/tools/process_registry.py b/tools/process_registry.py index 57709bc29..479030120 100644 --- a/tools/process_registry.py +++ b/tools/process_registry.py @@ -776,7 +776,7 @@ class ProcessRegistry: # Only enqueue completion notification on the FIRST move. Without # this guard, kill_process() and the reader thread can both call - # _move_to_finished(), producing duplicate [SYSTEM: ...] messages. + # _move_to_finished(), producing duplicate [IMPORTANT: ...] messages. if was_running and session.notify_on_complete: from tools.ansi_strip import strip_ansi output_tail = strip_ansi(session.output_buffer[-2000:]) if session.output_buffer else ""