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]
Fix HumanThoughtModel response parsing
John Yange7598d89cbaa
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 043b0a97..f64818ba 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -564,10 +564,7 @@ class Agent:if isinstance(self.model, HumanThoughtModel):# TODO: This might be a bit hacky# consider changing sweagent/tools/tools.py:ToolConfig to enforce this.- step.thought, step.action = ThoughtActionParser()(- output["message"],- self.tools.config.commands- )+ step.thought, step.action = ThoughtActionParser()(output, self.tools.config.commands)elif isinstance(self.model, HumanModel):step.thought, step.action = "", output["message"]else:diff --git a/sweagent/agent/models.py b/sweagent/agent/models.pyindex 0ccc5905..f66169c4 100644--- a/sweagent/agent/models.py+++ b/sweagent/agent/models.py@@ -180,7 +180,7 @@ class HumanModel(AbstractModel):command.name: command.end_name for command in tools.commands if command.end_name is not None}- def query(self, history: History, action_prompt: str = "> ") -> dict:+ def _query(self, history: History, action_prompt: str = "> ") -> dict:"""Logic for handling user input to pass to SWEEnv"""action = input(action_prompt)command_name = action.split()[0] if action.strip() else ""@@ -204,7 +204,11 @@ class HumanModel(AbstractModel):breakbuffer.append(action)action = "\n".join(buffer)- return {"message": action}+ return action++ def query(self, history: History, action_prompt: str = "> ") -> dict:+ """Wrapper to separate action prompt from formatting"""+ return {"message": self._query(history, action_prompt)}class HumanThoughtModel(HumanModel):@@ -220,7 +224,7 @@ class HumanThoughtModel(HumanModel):thought_all += thoughtthought = input("... ")- action = super().query(history, action_prompt="Action: ")+ action = super()._query(history, action_prompt="Action: ")return {"message": f"{thought_all}\n```\n{action}\n```"}