diff --git a/gptme/message.py b/gptme/message.py index 48b7db081..9b0bddf7c 100644 --- a/gptme/message.py +++ b/gptme/message.py @@ -211,6 +211,15 @@ def format_msgs( if highlight: color = ROLE_COLOR[msg.role] userprefix = f"[bold {color}]{userprefix}[/bold {color}]" + if msg.role == "system": + first_line = msg.content.split("\n", 1)[0].lower() + isSuccess = first_line.startswith(("saved", "appended", "patch successfully", "ran")) + isError = first_line.startswith(("error", "failed")) + if isSuccess: + userprefix = f"{userprefix} ✅" + elif isError: + userprefix = f"{userprefix} ❌" + # get terminal width max_len = shutil.get_terminal_size().columns - len(userprefix) output = "" diff --git a/gptme/tools/patch.py b/gptme/tools/patch.py index 15febd0de..25c3094fd 100644 --- a/gptme/tools/patch.py +++ b/gptme/tools/patch.py @@ -257,7 +257,7 @@ def execute_patch( code = kwargs.get("patch", code) if not code: - yield Message("system", "No patch provided by the assistant") + yield Message("system", "Error: No patch provided by the assistant") return yield from execute_with_confirmation( diff --git a/gptme/tools/shell.py b/gptme/tools/shell.py index e8043b90f..a94599fb2 100644 --- a/gptme/tools/shell.py +++ b/gptme/tools/shell.py @@ -289,13 +289,15 @@ def execute_shell_impl( stdout = _shorten_stdout(stdout.strip(), pre_tokens=2000, post_tokens=8000) stderr = _shorten_stdout(stderr.strip(), pre_tokens=2000, post_tokens=2000) - msg = ( - _format_block_smart( - f"Ran {'allowlisted ' if allowlisted else ''}command", cmd, lang="bash" - ) - + "\n\n" + _format_block_smart( + f"{'Failed to run' if returncode else 'Ran'} " + f"{'allowlisted ' if allowlisted else ''}command", + cmd, + lang="bash" ) + + "\n\n" +) if stdout: msg += _format_block_smart("", stdout, "stdout") + "\n\n" if stderr: diff --git a/gptme/tools/tmux.py b/gptme/tools/tmux.py index 5b0699913..75e6142cd 100644 --- a/gptme/tools/tmux.py +++ b/gptme/tools/tmux.py @@ -223,7 +223,7 @@ def execute_tmux( continue if len(parts) < 2: - yield Message("system", f"Missing arguments for command: {command}") + yield Message("system", f"Error: Missing arguments for command: {command}") continue _args = parts[1] @@ -237,7 +237,7 @@ def execute_tmux( elif command == "kill_session": yield kill_session(_args) else: - yield Message("system", f"Unknown command: {command}") + yield Message("system", f"Error: Unknown command: {command}") instructions = """