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]

Fix: Consistency of cost limits with human model (#1167)

Kilian Lieret09581536c30d
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.py
index a0e1abc6..127851b3 100644
--- a/sweagent/agent/models.py
+++ b/sweagent/agent/models.py
@@ -354,10 +354,10 @@ class HumanModel(AbstractModel):
) -> None:
self.stats.instance_cost += self.config.cost_per_call
self.stats.api_calls += 1
- if self.stats.instance_cost > self.config.per_instance_cost_limit:
+ if 0 < self.config.per_instance_cost_limit < self.stats.instance_cost:
msg = f"Instance cost limit exceeded: {self.stats.instance_cost} > {self.config.per_instance_cost_limit}"
raise InstanceCostLimitExceededError(msg)
- if self.stats.instance_cost > self.config.total_cost_limit:
+ if 0 < self.config.total_cost_limit < self.stats.instance_cost:
msg = f"Total cost limit exceeded: {self.stats.instance_cost} > {self.config.total_cost_limit}"
raise TotalCostLimitExceededError(msg)