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]
Add exception message to available format vars
Kilian Liereta8475f4fe8f9
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 3f43a723..ffebe4cd 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -665,10 +665,12 @@ class Agent:"""Requeries the model if the error is a format/blocklist/bash syntax error."""step = getattr(exception, "step", StepOutput())self.add_step_to_trajectory(step)+ exception_message = getattr(exception, "message", "")return self.get_model_requery_history(error_template=template,**step.model_dump(),**getattr(exception, "extra_info", {}),+ exception_message=exception_message,)n_fails = 0diff --git a/sweagent/tools/parsing.py b/sweagent/tools/parsing.pyindex 9c28c713..778207c3 100644--- a/sweagent/tools/parsing.py+++ b/sweagent/tools/parsing.py@@ -5,7 +5,7 @@ import reimport textwrapfrom abc import ABC, abstractmethodfrom shlex import quote-from typing import Literal+from typing import Any, Literalfrom pydantic import BaseModel@@ -27,9 +27,10 @@ class FunctionCallingFormatError(FormatError):error_code: Literal["missing", "multiple", "incorrect_args", "invalid_json", "invalid_command", "missing_arg", "unexpected_arg"],+ **extra_info: Any,):super().__init__(message + f"[error_code={error_code}]")- self.extra_info = {"error_code": error_code}+ self.extra_info = {"error_code": error_code, **extra_info}class AbstractParseFunction(ABC):@@ -240,7 +241,7 @@ class FunctionCallingParser(AbstractParseFunction, BaseModel):"""Expects the model response to be a LiteLLM tool call."""error_message: str = """\- Your output could not be parsed properly.+ Your action could not be parsed properly.Please make sure your output includes a thought and exactly _ONE_ function call.Make sure your function call doesn't include any extra arguments that are not in the allowed arguments, and only use the allowed commands.@@ -296,7 +297,7 @@ class FunctionCallingParser(AbstractParseFunction, BaseModel):f"tool calls with message: {message}")error_code = "missing" if num_tools == 0 else "multiple"- raise FunctionCallingFormatError(msg, error_code)+ raise FunctionCallingFormatError(msg, error_code, num_tools=num_tools)tool_call = tool_calls[0]action = self._parse_tool_call(tool_call, commands)return message, action