SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Web: Shorten long error messages in banner (#361)
Kilian Lieretc9b06d1cdb70
diff --git a/sweagent/api/hooks.py b/sweagent/api/hooks.pyindex 8e331c61..78ce246e 100644--- a/sweagent/api/hooks.py+++ b/sweagent/api/hooks.py@@ -41,9 +41,13 @@ class WebUpdate:"""Directly wrap around socketio.emit"""self._socketio.emit(event, data)- def up_log(self, message: str, level="info"):+ def up_log(self, message: str):"""Update the log"""- self._emit("log_message", {"message": message, "level": level})+ self._emit("log_message", {"message": message})++ def up_banner(self, message: str):+ """Update the banner"""+ self._emit("update_banner", {"message": message})def up_agent(self,diff --git a/sweagent/api/server.py b/sweagent/api/server.pyindex ff07fb67..c8bfdb32 100644--- a/sweagent/api/server.py+++ b/sweagent/api/server.py@@ -78,10 +78,14 @@ class MainThread(ThreadWithExc):main.env.add_hook(EnvUpdateHook(self._wu))main.main()except Exception as e:- self._wu.up_agent(f"Error (see log for details): {e}")+ short_msg = str(e)+ max_len = 350+ if len(short_msg) > max_len:+ short_msg = f"{short_msg[:max_len]}... (see log for details)"traceback_str = traceback.format_exc()self._wu.up_log(traceback_str)- self._wu.up_log(str(e), level="critical")+ self._wu.up_agent(f"Error: {short_msg}")+ self._wu.up_banner("Critical error: " + short_msg)self._wu.finish_run()raise@@ -131,6 +135,9 @@ def run():wu.up_agent("Starting the run")# Use Any type to silence annoying false positives from mypyrun: Any = AttrDict.from_nested_dicts(json.loads(request.args["runConfig"]))+ print(run)+ print(run.environment)+ print(run.environment.base_commit)model_name: str = run.agent.model.model_nameenvironment_setup = ""environment_input_type = run.environment.environment_setup.input_typediff --git a/sweagent/frontend/src/Run.js b/sweagent/frontend/src/Run.jsindex 87a87008..97e10f29 100644--- a/sweagent/frontend/src/Run.js+++ b/sweagent/frontend/src/Run.js@@ -185,13 +185,13 @@ function Run() {logsRef.current.scrollTop = logsRef.current.scrollHeight;};+ const handleUpdateBanner = (data) => {+ setErrorBanner(data.message);+ };+const handleLogMessage = (data) => {requeueStopComputeTimeout();setLogs((prevLogs) => prevLogs + data.message);- if (data.level === "critical") {- console.log("Critical error", data.message);- setErrorBanner("Critical errror encountered: " + data.message);- }if (logsRef.current) {setTimeout(() => {scrollLog();@@ -205,6 +205,7 @@ function Run() {socket.on("update", handleUpdate);socket.on("log_message", handleLogMessage);+ socket.on("update_banner", handleUpdateBanner);socket.on("finish_run", handleFinishedRun);socket.on("connect", () => {console.log("Connected to server");@@ -236,6 +237,7 @@ function Run() {socket.off("connect");socket.off("disconnect");socket.off("connect_error");+ socket.off("update_banner", handleUpdateBanner);};}, []);