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: Show critical errors in top banner
Kilian Lieretf5b29a8e80b2
diff --git a/sweagent/api/hooks.py b/sweagent/api/hooks.pyindex 2f3fdcad..af7bf70f 100644--- a/sweagent/api/hooks.py+++ b/sweagent/api/hooks.py@@ -37,9 +37,9 @@ class WebUpdate:"""Directly wrap around socketio.emit"""self._socketio.emit(event, data)- def up_log(self, message: str):+ def up_log(self, message: str, level="info"):"""Update the log"""- self._emit('log_message', {'message': message})+ self._emit('log_message', {'message': message, 'level': level})def up_agent(self,diff --git a/sweagent/api/server.py b/sweagent/api/server.pyindex 1fb49c7e..d75fe51d 100644--- a/sweagent/api/server.py+++ b/sweagent/api/server.py@@ -60,9 +60,10 @@ class MainThread(ThreadWithExc):main.agent.add_hook(AgentUpdateHook(self._wu))main.main()except Exception as e:- self._wu.up_agent(f"Error:\n```\n{e}\n```\n")+ self._wu.up_agent(f"Error (see log for details): {e}")traceback_str = traceback.format_exc()self._wu.up_log(traceback_str)+ self._wu.up_log(str(e), level="critical")self._wu.finish_run()raisediff --git a/sweagent/frontend/src/Run.js b/sweagent/frontend/src/Run.jsindex 47cda0e2..9be19549 100644--- a/sweagent/frontend/src/Run.js+++ b/sweagent/frontend/src/Run.js@@ -13,7 +13,7 @@ const socket = io(url);function Run() {const [isConnected, setIsConnected] = useState(socket.connected);- const [connectionError, setConnectionError] = useState('');+ const [errorBanner, setErrorBanner] = useState('');const [dataPath, setDataPath] = useState('https://github.com/klieret/swe-agent-test-repo/issues/1');const [repoPath, setRepoPath] = useState("");@@ -92,6 +92,7 @@ function Run() {setEnvFeed([]);setLogs('');setHighlightedStep(null);+ setErrorBanner('');try {await axios.get(`/run`, { params: { data_path: dataPath, test_run: testRun, repo_path: repoPath, model: model } });} catch (error) {@@ -123,13 +124,15 @@ function Run() {const scrollLog = () => {logsRef.current.scrollTop = logsRef.current.scrollHeight;- console.log('Scrolling to bottom', logsRef.current.scrollHeight);}const handleLogMessage = (data) => {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();}, 100);@@ -146,20 +149,20 @@ function Run() {socket.on('connect', () => {console.log("Connected to server");setIsConnected(true);- setConnectionError(''); // Clear any errors on successful connection+ setErrorBanner(''); // Clear any errors on successful connection});socket.on('disconnect', () => {console.log("Disconnected from server");setIsConnected(false);- setConnectionError('Connection to server lost.');+ setErrorBanner('Connection to flask server lost, please restart it.');setIsComputing(false);scrollLog(); // reveal copy button});socket.on('connect_error', (error) => {setIsConnected(false);- setConnectionError('Failed to connect to server.');+ setErrorBanner('Failed to connect to the flask server, please restart it.');setIsComputing(false);scrollLog(); // reveal copy button});@@ -175,10 +178,14 @@ function Run() {}, []);function renderErrorMessage() {- if (!isConnected && connectionError) {+ if (errorBanner) {return (- <div class="alert alert-danger" role="alert">- {connectionError}+ <div className="alert alert-danger" role="alert">+ {errorBanner}+ <br/>+ If you think this was a bug, please head over to <a href="https://github.com/princeton-nlp/swe-agent/issues" target='blank'>our GitHub issue tracker</a>,+ check if someone has already reported the issue, and if not, create a new issue.+ Please include the full log, all settings that you entered, and a screenshot of this page.</div>);}diff --git a/sweagent/frontend/src/components/controls/LRunControl.js b/sweagent/frontend/src/components/controls/LRunControl.jsindex c5eb2032..2a27caab 100644--- a/sweagent/frontend/src/components/controls/LRunControl.js+++ b/sweagent/frontend/src/components/controls/LRunControl.js@@ -81,7 +81,7 @@ function LRunControl({isComputing, isConnected, handleStop, handleSubmit, setDat<span className="input-group-text">Model name</span><input type="text" className="form-control" placeholder="gpt4" onChange={(e) => setModel(e.target.value || "gpt4")} /></div>- <div class="alert alert-info" role="alert">+ <div className="alert alert-info" role="alert">Please make sure that you have your API keys set in keys.cfg</div></div>@@ -100,19 +100,19 @@ function LRunControl({isComputing, isConnected, handleStop, handleSubmit, setDat</Tabs><div className="runControl p-3"><div>- <div class="btn-group" role="group" aria-label="Basic example">+ <div className="btn-group" role="group" aria-label="Basic example"><button type="submit" className="btn btn-primary" onClick={handleSubmit} disabled={isComputing || !isConnected}><PlayFill/> Run</button><button onClick={handleStop} disabled={!isComputing} className="btn btn-primary"><StopFill/> Stop</button></div></div><div className="extraButtons">- <div class="btn-group" role="group" aria-label="Basic example">+ <div className="btn-group" role="group" aria-label="Basic example"><Linkto="https://github.com/princeton-nlp/SWE-agent"target="_blank"rel="noopener noreferrer">- <button type="button" class="btn btn-outline-secondary">GitHub readme</button>+ <button type="button" className="btn btn-outline-secondary">GitHub readme</button></Link></div></div>diff --git a/sweagent/frontend/src/components/panels/LogPanel.js b/sweagent/frontend/src/components/panels/LogPanel.jsindex 98663b20..f22e9235 100644--- a/sweagent/frontend/src/components/panels/LogPanel.js+++ b/sweagent/frontend/src/components/panels/LogPanel.js@@ -37,7 +37,7 @@ const LogPanel = ({ logs, logsRef, isComputing }) => {<pre id="logContent">{logs}</pre><div style={{ clear: "both", marginTop: '1em' }}/></div>- { !isComputing &&+ { !isComputing && logs &&<div style={{ display: 'flex', justifyContent: 'center', width: '100%' }}><Button variant="light" onClick={handleCopy} style={{marginBottom: 20, marginRight: 20}}><Clipboard /> Copy to clipboard