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]

Somewhat hacky way to mirror bash prompts

Kilian Lieret37e8b1165523
diff --git a/sweagent/tools/commands.py b/sweagent/tools/commands.py
index ced75cbf..4c3a3469 100644
--- a/sweagent/tools/commands.py
+++ b/sweagent/tools/commands.py
@@ -192,8 +192,8 @@ class Command(BaseModel):
if not re.match(ARGUMENT_NAME_PATTERN, arg.name):
msg = f"Command '{self.name}': Invalid argument name: '{arg.name}'"
raise ValueError(msg)
- if _extract_keys(self.invoke_format) != {arg.name for arg in self.arguments}:
- msg = f"Command '{self.name}': Argument names in signature / invoke_format do not match argument names"
+ if (invoke_keys := _extract_keys(self.invoke_format)) != {arg.name for arg in self.arguments}:
+ msg = f"Command '{self.name}': Argument names ({invoke_keys}) in signature / invoke_format {self.invoke_format!r} do not match argument names"
raise ValueError(msg)
return self
@@ -201,7 +201,7 @@ class Command(BaseModel):
# Default Bash tool
BASH_COMMAND = Command(
name="bash",
- signature="<command>",
+ signature="echo '<command>'\n<command>\necho \"root@workspace:${{PWD}} #\n[Command finished with exit code ${{?}}]\"",
docstring="runs the given command directly in bash",
arguments=[
Argument(
diff --git a/sweagent/tools/parsing.py b/sweagent/tools/parsing.py
index 4e28b1cf..4c0257bf 100644
--- a/sweagent/tools/parsing.py
+++ b/sweagent/tools/parsing.py
@@ -301,6 +301,9 @@ class FunctionCallingParser(AbstractParseFunction, BaseModel):
else ""
for arg in command.arguments
}
+ print(formatted_args)
+ print(command.invoke_format)
+ print(command.invoke_format.format(**formatted_args))
return command.invoke_format.format(**formatted_args).strip()
def __call__(self, model_response: dict, commands: list[Command], strict=False):