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: Work around litellm claude 3.7 tokens to 128k (#1106)
Kilian Lieretdd3aadc386f3
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.pyindex ee88878e..2c98681c 100644--- a/sweagent/agent/models.py+++ b/sweagent/agent/models.py@@ -580,6 +580,19 @@ class LiteLLMModel(AbstractModel):self.model_max_output_tokens = self.config.max_output_tokenselse:self.model_max_output_tokens = litellm.model_cost.get(self.config.name, {}).get("max_output_tokens")+ # Special handling for Claude 3.7 models to set 64k context by default when beta header not present+ # See https://github.com/SWE-agent/SWE-agent/pull/1016+ is_claude_3_7 = "claude-3-7-sonnet" in self.config.name+ has_128k_beta_header = (+ self.config.completion_kwargs.get("extra_headers", {}).get("anthropic-beta") == "output-128k-2025-02-19"+ )+ if is_claude_3_7 and not has_128k_beta_header:+ self.model_max_output_tokens = 64000+ self.logger.warning(+ "Claude 3.7 models do not support 128k context by default. "+ "Setting max output tokens to 64k. To enable 128k context, please set the "+ "completion_kwargs to {'extra_headers': {'anthropic-beta': 'output-128k-2025-02-19'}}."+ )self.lm_provider = litellm.model_cost.get(self.config.name, {}).get("litellm_provider")