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]

Doc: More information on history processors

Kilian Lieret5bf1d0df02b3
diff --git a/docs/reference/history_processor_config.md b/docs/reference/history_processor_config.md
index e3246dbd..068164f6 100644
--- a/docs/reference/history_processor_config.md
+++ b/docs/reference/history_processor_config.md
@@ -3,6 +3,15 @@
History processors can filter the history/trajectory to query the model.
For example, a very simple history processor would be one that strips away old observations to reduce context when querying the model.
+You can set them as follows:
+
+```yaml
+agent:
+ history_processors:
+ - type: last_n_observations
+ n: 5
+```
+
::: sweagent.agent.history_processors.DefaultHistoryProcessor
::: sweagent.agent.history_processors.LastNObservations
diff --git a/sweagent/agent/history_processors.py b/sweagent/agent/history_processors.py
index c22f57ea..9f030a86 100644
--- a/sweagent/agent/history_processors.py
+++ b/sweagent/agent/history_processors.py
@@ -75,7 +75,33 @@ class DefaultHistoryProcessor(BaseModel):
class LastNObservations(BaseModel):
- """Keep the last n observations or remove tagged observations."""
+ """Elide all but the last n observations or remove tagged observations.
+
+ This is our most classic history processor, used in the original paper
+ to elide but the last 5 observations.
+ Elided observations are replaced by "Old environment output: (n lines omitted)".
+
+ Typical configuration:
+
+ ```yaml
+ agent:
+ history_processors:
+ - type: last_n_observations
+ n: 5
+ ```
+
+ as for example in use in the SWE-agent 0.7 config at
+ https://github.com/SWE-agent/SWE-agent/blob/main/config/sweagent_0_7/07.yaml
+
+ For most use cases, you only need to set `n`.
+
+ Note that using this history processor will break prompt caching (as the
+ history of every query will change every time due to the elided observations).
+ There are some workarounds possible with the `polling` parameter.
+
+ However, most SotA models can now fit a lot of context, so generally this
+ history processor is not always needed anymore.
+ """
n: int
"""Number of observations to keep."""