mini-swe-agent 1.14.0__py3-none-any.whl → 1.14.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-swe-agent
3
- Version: 1.14.0
3
+ Version: 1.14.2
4
4
  Summary: Nano SWE Agent - A simple AI software engineering agent
5
5
  Author-email: Kilian Lieret <kilian.lieret@posteo.de>, "Carlos E. Jimenez" <carlosej@princeton.edu>
6
6
  License: MIT License
@@ -1,5 +1,5 @@
1
- mini_swe_agent-1.14.0.dist-info/licenses/LICENSE.md,sha256=D3luWPkdHAe7LBsdD4vzqDAXw6Xewb3G-uczss0uh1s,1094
2
- minisweagent/__init__.py,sha256=x76NxcXdWcajgoVsrPVO4EaR79r1Bnk3bF6wifAmcYo,2016
1
+ mini_swe_agent-1.14.2.dist-info/licenses/LICENSE.md,sha256=D3luWPkdHAe7LBsdD4vzqDAXw6Xewb3G-uczss0uh1s,1094
2
+ minisweagent/__init__.py,sha256=2IFYCWunKVGyxCxI2odK8QE4qIrVNJ4bg1ekPF-7izA,2016
3
3
  minisweagent/__main__.py,sha256=FIyAOiw--c3FQ2g240FOM1FdL0lk_PxSpixu0pQ7WFo,194
4
4
  minisweagent/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  minisweagent/agents/__init__.py,sha256=cpjJLzg1IGxLM-tZpoMJV9S33ye13XtdBO0x7DU_Lrk,48
@@ -25,14 +25,14 @@ minisweagent/environments/extra/bubblewrap.py,sha256=G12Dm63N30qByfLb1SKNsI4G4gL
25
25
  minisweagent/environments/extra/swerex_docker.py,sha256=WPYbohT_vqTHkde9cxpbV6chLXCpLl0PDAcgMbZsV0M,1707
26
26
  minisweagent/models/__init__.py,sha256=Ol95N3oEDlojz7IBw10A7xf5rKfxtjESyJuEWOwZyzo,4171
27
27
  minisweagent/models/anthropic.py,sha256=4p-LxQ_RYQUX1rBsffAj3T1bBb2uMRhA4IyKfDcMpgo,1517
28
- minisweagent/models/litellm_model.py,sha256=qAYsFBzZGPRGGQfbNCJXKH9eRpzmJKZ9ORTJHsOdhL0,3419
29
- minisweagent/models/openrouter_model.py,sha256=7SwS4Raw-i_gAM9AGJ8EWoTrnCP8MfHqWf7UZ0sb4ds,4095
30
- minisweagent/models/portkey_model.py,sha256=lARromtKwiXJtxxXScOkp9PCl3oS76QMQh_6DeehoiI,4895
28
+ minisweagent/models/litellm_model.py,sha256=2kPpmVLvt306FoLdEYnNfTprEkWl3PCxZldQxLLdp0k,3475
29
+ minisweagent/models/openrouter_model.py,sha256=cyy1scXegAwpta9QeSX7J7nJrZDt1Hre5MybHKgm4Pk,4151
30
+ minisweagent/models/portkey_model.py,sha256=MZP6VF_TvHqlcuR7s6JeiE8LzHn9CE99G1Q_eeRTdHg,5835
31
31
  minisweagent/models/test_models.py,sha256=ItCA6ddntzkYA7dzSuUEaLMV-AE8TBuXBFP8CzpiO3U,1351
32
32
  minisweagent/models/extra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  minisweagent/models/extra/roulette.py,sha256=SqLj_wz9Vkbxou7i9Ef4Uzmg_eheDouNySkkV7pm2Ys,2093
34
34
  minisweagent/models/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- minisweagent/models/utils/cache_control.py,sha256=rAjW_FPWxG7bnuNe94CARAq9LKaTgFtSSp9zMQvssRs,2535
35
+ minisweagent/models/utils/cache_control.py,sha256=zgi9e_72Y1pc0qNirW8_rMyi8RcLonGJNtfavqGX5_I,1917
36
36
  minisweagent/models/utils/key_per_thread.py,sha256=4YZXATIw-Fozi7M-1i-wyjIBf-GtQM71kkOHxSPkwrE,748
37
37
  minisweagent/run/__init__.py,sha256=WIoYgHVl7iZF2YncrfV3IttupG6P5KogroKHKECka3A,38
38
38
  minisweagent/run/github_issue.py,sha256=35mZoPLc4JV6XXJKRv55lnuKbXf5lDftd51N89-x9J0,3192
@@ -50,8 +50,8 @@ minisweagent/run/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
50
50
  minisweagent/run/utils/save.py,sha256=2xd-UnUzI7Fr_AUZ5KEJ53Aa4kpuuGYxkLwyUcvqyMM,2503
51
51
  minisweagent/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  minisweagent/utils/log.py,sha256=ruDMNKMrVC9NPvCeHwO3QYz5jsVNUGQB2dRAEAPAWp8,996
53
- mini_swe_agent-1.14.0.dist-info/METADATA,sha256=_quEJiibMIZ98LVaarGvBumSvBXWihTaeelQMGF7Wf8,14151
54
- mini_swe_agent-1.14.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
- mini_swe_agent-1.14.0.dist-info/entry_points.txt,sha256=d1_yRbTaGjs1UXHa6JQK0sKDGBIVGm8oeW0k2kfbJgQ,182
56
- mini_swe_agent-1.14.0.dist-info/top_level.txt,sha256=zKF4t8bFpV87fdVABZt2Da-vnb4Vkh_CxkwQx5YT4Ew,13
57
- mini_swe_agent-1.14.0.dist-info/RECORD,,
53
+ mini_swe_agent-1.14.2.dist-info/METADATA,sha256=FZdq-wii7a27AFfe8jv5pUCEC2hRvUxOZNqUVNS6yFc,14151
54
+ mini_swe_agent-1.14.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
+ mini_swe_agent-1.14.2.dist-info/entry_points.txt,sha256=d1_yRbTaGjs1UXHa6JQK0sKDGBIVGm8oeW0k2kfbJgQ,182
56
+ mini_swe_agent-1.14.2.dist-info/top_level.txt,sha256=zKF4t8bFpV87fdVABZt2Da-vnb4Vkh_CxkwQx5YT4Ew,13
57
+ mini_swe_agent-1.14.2.dist-info/RECORD,,
minisweagent/__init__.py CHANGED
@@ -8,7 +8,7 @@ This file provides:
8
8
  unless you want the static type checking.
9
9
  """
10
10
 
11
- __version__ = "1.14.0"
11
+ __version__ = "1.14.2"
12
12
 
13
13
  import os
14
14
  from pathlib import Path
@@ -76,6 +76,7 @@ class LitellmModel:
76
76
  )
77
77
  raise
78
78
  self.n_calls += 1
79
+ assert cost >= 0.0, f"Cost is negative: {cost}"
79
80
  self.cost += cost
80
81
  GLOBAL_MODEL_STATS.add(cost)
81
82
  return {
@@ -100,6 +100,7 @@ class OpenRouterModel:
100
100
  # Extract cost from usage information
101
101
  usage = response.get("usage", {})
102
102
  cost = usage.get("cost", 0.0)
103
+ assert cost >= 0.0, f"Cost is negative: {cost}"
103
104
 
104
105
  # If total_cost is not available, raise an error
105
106
  if cost == 0.0:
@@ -95,6 +95,17 @@ class PortkeyModel:
95
95
  if self.config.litellm_model_name_override:
96
96
  if response_for_cost_calc.model:
97
97
  response_for_cost_calc.model = self.config.litellm_model_name_override
98
+ prompt_tokens = response_for_cost_calc.usage.prompt_tokens
99
+ total_tokens = response_for_cost_calc.usage.total_tokens
100
+ completion_tokens = response_for_cost_calc.usage.completion_tokens
101
+ if total_tokens - prompt_tokens - completion_tokens != 0:
102
+ # This is most likely related to how portkey treats cached tokens: It doesn't count them towards the prompt tokens (?)
103
+ logger.warning(
104
+ f"WARNING: Total tokens - prompt tokens - completion tokens != 0: {response_for_cost_calc.model_dump()}."
105
+ " This is probably a portkey bug or incompatibility with litellm cost tracking. "
106
+ "Setting prompt tokens based on total tokens and completion tokens. You might want to double check your costs."
107
+ )
108
+ response_for_cost_calc.usage.prompt_tokens = total_tokens - completion_tokens
98
109
  try:
99
110
  cost = litellm.cost_calculator.completion_cost(
100
111
  response_for_cost_calc, model=self.config.litellm_model_name_override or None
@@ -106,6 +117,7 @@ class PortkeyModel:
106
117
  "https://klieret.short.gy/litellm-model-registry Still stuck? Please open a github issue for help!"
107
118
  )
108
119
  raise
120
+ assert cost >= 0.0, f"Cost is negative: {cost}"
109
121
 
110
122
  self.n_calls += 1
111
123
  self.cost += cost
@@ -38,35 +38,17 @@ def set_cache_control(
38
38
  messages: list[dict], *, mode: Literal["default_end"] | None = "default_end", last_n_messages_offset: int = 0
39
39
  ) -> list[dict]:
40
40
  """This messages processor adds manual cache control marks to the messages."""
41
+ # ONLY ADD TO THE LAST MESSAGE
41
42
  if mode != "default_end":
42
43
  raise ValueError(f"Invalid mode: {mode}")
43
44
  if last_n_messages_offset:
44
- warnings.warn("last_n_messages_offset is deprecated and will be removed in the future")
45
- messages = copy.deepcopy(messages)
46
-
47
- # Find all user messages
48
- user_message_indices = []
49
- for i, msg in enumerate(messages):
50
- if msg["role"] == "user":
51
- user_message_indices.append(i)
45
+ warnings.warn("last_n_messages_offset is deprecated and will be removed in the future. It has no effect.")
52
46
 
53
- # Clear cache control from all messages first
54
- for entry in messages:
47
+ messages = copy.deepcopy(messages)
48
+ new_messages = []
49
+ for i_entry, entry in enumerate(reversed(messages)):
55
50
  _clear_cache_control(entry)
56
-
57
- # Add cache control to user messages, respecting offset
58
- if user_message_indices:
59
- # If offset is specified, exclude the last N messages from getting cache control
60
- messages_to_cache = user_message_indices
61
- if last_n_messages_offset > 0:
62
- messages_to_cache = (
63
- user_message_indices[:-last_n_messages_offset]
64
- if last_n_messages_offset < len(user_message_indices)
65
- else []
66
- )
67
-
68
- # Add cache control to the selected user messages
69
- for idx in messages_to_cache:
70
- _set_cache_control(messages[idx])
71
-
72
- return messages
51
+ if i_entry == 0:
52
+ _set_cache_control(entry)
53
+ new_messages.append(entry)
54
+ return list(reversed(new_messages))