Skip to content

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]

Inspector: Show action summary

Kilian Lieret41dca6ad4052
diff --git a/sweagent/inspector/fileViewer.js b/sweagent/inspector/fileViewer.js
index f7533ffb..0bac152b 100644
--- a/sweagent/inspector/fileViewer.js
+++ b/sweagent/inspector/fileViewer.js
@@ -164,9 +164,8 @@ function fetchDirectoryInfo() {
.then((data) => {
if (data.directory) {
trajectoryDirectory = data.directory; // Store the directory
- document.title = `Trajectory Viewer: ${data.directory}`;
- document.querySelector("h1").textContent =
- `Trajectory Viewer: ${data.directory}`;
+ document.getElementById("directoryInfo").textContent =
+ `Directory: ${data.directory}`;
}
})
.catch((error) => console.error("Error fetching directory info:", error));
diff --git a/sweagent/inspector/index.html b/sweagent/inspector/index.html
index 48887f7c..ed9ad496 100644
--- a/sweagent/inspector/index.html
+++ b/sweagent/inspector/index.html
@@ -10,6 +10,7 @@
<body>
<div class="container">
<h1>Trajectory File Viewer</h1>
+ <h3 id="directoryInfo"></h3>
<ul id="fileList"></ul>
<label style="margin-right: 20px;">
<input type="checkbox" id="showDemos" onchange="refreshCurrentFile()"> Show demonstrations
diff --git a/sweagent/inspector/server.py b/sweagent/inspector/server.py
index a91053a9..f4361b9c 100644
--- a/sweagent/inspector/server.py
+++ b/sweagent/inspector/server.py
@@ -138,6 +138,27 @@ def append_results(traj_path: Path, instance_id: str, content, results, results_
return content
+def get_action_summary(content):
+ out = ""
+ i = 0
+ for item in content["history"]:
+ if item["role"] != "assistant":
+ continue
+ if item.get("is_demo"):
+ continue
+ i += 1
+ try:
+ action = item["action"]
+ except KeyError:
+ print(f"No action for step {i}")
+ print(item)
+ raise
+ if len(action) > 70:
+ action = action[:67] + "..."
+ out += f"Step {i}: {action}\n"
+ return out
+
+
def load_content(file_name, gold_patches, test_patches) -> dict[str, Any]:
with open(file_name) as infile:
content = json.load(infile)
@@ -153,6 +174,7 @@ def load_content(file_name, gold_patches, test_patches) -> dict[str, Any]:
content = append_exit(content) # accommodate new and old format
content = append_patch(Path(file_name).stem, content, gold_patches, "Gold")
content = append_patch(Path(file_name).stem, content, test_patches, "Test")
+ content["history"].insert(0, {"role": "Action Summary", "content": get_action_summary(content)})
return append_results(
Path(file_name),
Path(file_name).stem,