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]
Ref(hp): Use pydantic field validators
Kilian Lieretfb8f096d3de6
diff --git a/sweagent/agent/history_processors.py b/sweagent/agent/history_processors.pyindex 9139205d..e1a2625f 100644--- a/sweagent/agent/history_processors.py+++ b/sweagent/agent/history_processors.py@@ -5,7 +5,7 @@ import refrom abc import abstractmethodfrom typing import Annotated, Literal, Protocol-from pydantic import BaseModel, ConfigDict, Field+from pydantic import BaseModel, ConfigDict, Field, field_validatorfrom sweagent.types import History, HistoryItem@@ -96,11 +96,15 @@ class LastNObservations(BaseModel):# pydantic configmodel_config = ConfigDict(extra="forbid")- def __call__(self, history: History) -> History:- if self.n <= 0:+ @field_validator("n")+ def validate_n(cls, n: int) -> int:+ if n <= 0:msg = "n must be a positive integer"raise ValueError(msg)- new_history = list()+ return n++ def __call__(self, history: History) -> History:+ new_history = []observation_idxs = [idxfor idx, entry in enumerate(history)