mini-swe-agent 1.14.4__tar.gz → 1.15.0__tar.gz

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.
Files changed (62) hide show
  1. {mini_swe_agent-1.14.4/src/mini_swe_agent.egg-info → mini_swe_agent-1.15.0}/PKG-INFO +15 -14
  2. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/README.md +14 -13
  3. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0/src/mini_swe_agent.egg-info}/PKG-INFO +15 -14
  4. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/__init__.py +1 -1
  5. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/litellm_model.py +16 -7
  6. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/openrouter_model.py +9 -8
  7. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/portkey_model.py +33 -23
  8. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/mini.py +1 -2
  9. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/utils/save.py +3 -1
  10. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/LICENSE.md +0 -0
  11. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/pyproject.toml +0 -0
  12. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/setup.cfg +0 -0
  13. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/mini_swe_agent.egg-info/SOURCES.txt +0 -0
  14. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/mini_swe_agent.egg-info/dependency_links.txt +0 -0
  15. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/mini_swe_agent.egg-info/entry_points.txt +0 -0
  16. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/mini_swe_agent.egg-info/requires.txt +0 -0
  17. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/mini_swe_agent.egg-info/top_level.txt +0 -0
  18. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/__main__.py +0 -0
  19. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/agents/__init__.py +0 -0
  20. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/agents/default.py +0 -0
  21. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/agents/interactive.py +0 -0
  22. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/agents/interactive_textual.py +0 -0
  23. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/README.md +0 -0
  24. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/__init__.py +0 -0
  25. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/default.yaml +0 -0
  26. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/extra/__init__.py +0 -0
  27. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/extra/swebench.yaml +0 -0
  28. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/extra/swebench_roulette.yaml +0 -0
  29. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/github_issue.yaml +0 -0
  30. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/mini.tcss +0 -0
  31. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/mini.yaml +0 -0
  32. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/config/mini_no_temp.yaml +0 -0
  33. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/environments/__init__.py +0 -0
  34. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/environments/docker.py +0 -0
  35. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/environments/extra/__init__.py +0 -0
  36. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/environments/extra/bubblewrap.py +0 -0
  37. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/environments/extra/swerex_docker.py +0 -0
  38. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/environments/local.py +0 -0
  39. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/environments/singularity.py +0 -0
  40. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/__init__.py +0 -0
  41. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/anthropic.py +0 -0
  42. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/extra/__init__.py +0 -0
  43. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/extra/roulette.py +0 -0
  44. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/test_models.py +0 -0
  45. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/utils/__init__.py +0 -0
  46. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/utils/cache_control.py +0 -0
  47. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/models/utils/key_per_thread.py +0 -0
  48. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/py.typed +0 -0
  49. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/__init__.py +0 -0
  50. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/extra/__init__.py +0 -0
  51. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/extra/config.py +0 -0
  52. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/extra/swebench.py +0 -0
  53. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/extra/swebench_single.py +0 -0
  54. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/extra/utils/__init__.py +0 -0
  55. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/extra/utils/batch_progress.py +0 -0
  56. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/github_issue.py +0 -0
  57. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/hello_world.py +0 -0
  58. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/inspector.py +0 -0
  59. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/mini_extra.py +0 -0
  60. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/run/utils/__init__.py +0 -0
  61. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/utils/__init__.py +0 -0
  62. {mini_swe_agent-1.14.4 → mini_swe_agent-1.15.0}/src/minisweagent/utils/log.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-swe-agent
3
- Version: 1.14.4
3
+ Version: 1.15.0
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
@@ -248,7 +248,7 @@ agent.run("Write a sudoku game")
248
248
 
249
249
  ## Let's get started!
250
250
 
251
- Option 1: Install + run in virtual environment
251
+ **Option 1:** If you just want to try out the CLI (package installed in anonymous virtual environment)
252
252
 
253
253
  ```bash
254
254
  pip install uv && uvx mini-swe-agent [-v]
@@ -256,19 +256,19 @@ pip install uv && uvx mini-swe-agent [-v]
256
256
  pip install pipx && pipx ensurepath && pipx run mini-swe-agent [-v]
257
257
  ```
258
258
 
259
- Option 2: Install in current environment
259
+ **Option 2:** Install CLI & python bindings in current environment
260
260
 
261
261
  ```bash
262
- pip install mini-swe-agent && mini [-v]
262
+ pip install mini-swe-agent
263
+ mini -v # run the CLI
263
264
  ```
264
265
 
265
- Option 3: Install from source
266
+ **Option 3:** Install from source (developer setup)
266
267
 
267
268
  ```bash
268
269
  git clone https://github.com/SWE-agent/mini-swe-agent.git
269
- cd mini-swe-agent
270
- pip install -e .
271
- mini [-v]
270
+ cd mini-swe-agent && pip install -e .
271
+ mini [-v] # run the CLI
272
272
  ```
273
273
 
274
274
  Read more in our [documentation](https://mini-swe-agent.com/latest/):
@@ -298,14 +298,15 @@ If you found this work helpful, please consider citing the [SWE-agent paper](htt
298
298
  Our other projects:
299
299
 
300
300
  <div align="center">
301
- <a href="https://github.com/SWE-agent/SWE-agent"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/sweagent_logo_text_below.svg" alt="SWE-agent" height="120px"></a>
301
+ <a href="https://github.com/SWE-agent/SWE-agent"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/sweagent_logo_text_below.svg" alt="SWE-agent" height="120px"></a>
302
302
  &nbsp;&nbsp;
303
- <a href="https://github.com/SWE-agent/SWE-ReX"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swerex_logo_text_below.svg" alt="SWE-ReX" height="120px"></a>
303
+ <a href="https://github.com/SWE-agent/SWE-ReX"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swerex_logo_text_below.svg" alt="SWE-ReX" height="120px"></a>
304
304
  &nbsp;&nbsp;
305
- <a href="https://github.com/SWE-bench/SWE-bench"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swebench_logo_text_below.svg" alt="SWE-bench" height="120px"></a>
305
+ <a href="https://github.com/SWE-bench/SWE-bench"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swebench_logo_text_below.svg" alt="SWE-bench" height="120px"></a>
306
306
  &nbsp;&nbsp;
307
- <a href="https://github.com/SWE-bench/SWE-smith"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swesmith_logo_text_below.svg" alt="SWE-smith" height="120px"></a>
307
+ <a href="https://github.com/SWE-bench/SWE-smith"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swesmith_logo_text_below.svg" alt="SWE-smith" height="120px"></a>
308
308
  &nbsp;&nbsp;
309
- <a href="https://github.com/SWE-bench/sb-cli"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/sbcli_logo_text_below.svg" alt="sb-cli" height="120px"></a>
309
+ <a href="https://github.com/codeclash-ai/codeclash"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/codeclash_logo_text_below.svg" alt="CodeClash" height="120px"></a>
310
+ &nbsp;&nbsp;
311
+ <a href="https://github.com/SWE-bench/sb-cli"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/sbcli_logo_text_below.svg" alt="sb-cli" height="120px"></a>
310
312
  </div>
311
-
@@ -178,7 +178,7 @@ agent.run("Write a sudoku game")
178
178
 
179
179
  ## Let's get started!
180
180
 
181
- Option 1: Install + run in virtual environment
181
+ **Option 1:** If you just want to try out the CLI (package installed in anonymous virtual environment)
182
182
 
183
183
  ```bash
184
184
  pip install uv && uvx mini-swe-agent [-v]
@@ -186,19 +186,19 @@ pip install uv && uvx mini-swe-agent [-v]
186
186
  pip install pipx && pipx ensurepath && pipx run mini-swe-agent [-v]
187
187
  ```
188
188
 
189
- Option 2: Install in current environment
189
+ **Option 2:** Install CLI & python bindings in current environment
190
190
 
191
191
  ```bash
192
- pip install mini-swe-agent && mini [-v]
192
+ pip install mini-swe-agent
193
+ mini -v # run the CLI
193
194
  ```
194
195
 
195
- Option 3: Install from source
196
+ **Option 3:** Install from source (developer setup)
196
197
 
197
198
  ```bash
198
199
  git clone https://github.com/SWE-agent/mini-swe-agent.git
199
- cd mini-swe-agent
200
- pip install -e .
201
- mini [-v]
200
+ cd mini-swe-agent && pip install -e .
201
+ mini [-v] # run the CLI
202
202
  ```
203
203
 
204
204
  Read more in our [documentation](https://mini-swe-agent.com/latest/):
@@ -228,14 +228,15 @@ If you found this work helpful, please consider citing the [SWE-agent paper](htt
228
228
  Our other projects:
229
229
 
230
230
  <div align="center">
231
- <a href="https://github.com/SWE-agent/SWE-agent"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/sweagent_logo_text_below.svg" alt="SWE-agent" height="120px"></a>
231
+ <a href="https://github.com/SWE-agent/SWE-agent"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/sweagent_logo_text_below.svg" alt="SWE-agent" height="120px"></a>
232
232
  &nbsp;&nbsp;
233
- <a href="https://github.com/SWE-agent/SWE-ReX"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swerex_logo_text_below.svg" alt="SWE-ReX" height="120px"></a>
233
+ <a href="https://github.com/SWE-agent/SWE-ReX"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swerex_logo_text_below.svg" alt="SWE-ReX" height="120px"></a>
234
234
  &nbsp;&nbsp;
235
- <a href="https://github.com/SWE-bench/SWE-bench"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swebench_logo_text_below.svg" alt="SWE-bench" height="120px"></a>
235
+ <a href="https://github.com/SWE-bench/SWE-bench"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swebench_logo_text_below.svg" alt="SWE-bench" height="120px"></a>
236
236
  &nbsp;&nbsp;
237
- <a href="https://github.com/SWE-bench/SWE-smith"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swesmith_logo_text_below.svg" alt="SWE-smith" height="120px"></a>
237
+ <a href="https://github.com/SWE-bench/SWE-smith"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swesmith_logo_text_below.svg" alt="SWE-smith" height="120px"></a>
238
238
  &nbsp;&nbsp;
239
- <a href="https://github.com/SWE-bench/sb-cli"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/sbcli_logo_text_below.svg" alt="sb-cli" height="120px"></a>
239
+ <a href="https://github.com/codeclash-ai/codeclash"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/codeclash_logo_text_below.svg" alt="CodeClash" height="120px"></a>
240
+ &nbsp;&nbsp;
241
+ <a href="https://github.com/SWE-bench/sb-cli"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/sbcli_logo_text_below.svg" alt="sb-cli" height="120px"></a>
240
242
  </div>
241
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-swe-agent
3
- Version: 1.14.4
3
+ Version: 1.15.0
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
@@ -248,7 +248,7 @@ agent.run("Write a sudoku game")
248
248
 
249
249
  ## Let's get started!
250
250
 
251
- Option 1: Install + run in virtual environment
251
+ **Option 1:** If you just want to try out the CLI (package installed in anonymous virtual environment)
252
252
 
253
253
  ```bash
254
254
  pip install uv && uvx mini-swe-agent [-v]
@@ -256,19 +256,19 @@ pip install uv && uvx mini-swe-agent [-v]
256
256
  pip install pipx && pipx ensurepath && pipx run mini-swe-agent [-v]
257
257
  ```
258
258
 
259
- Option 2: Install in current environment
259
+ **Option 2:** Install CLI & python bindings in current environment
260
260
 
261
261
  ```bash
262
- pip install mini-swe-agent && mini [-v]
262
+ pip install mini-swe-agent
263
+ mini -v # run the CLI
263
264
  ```
264
265
 
265
- Option 3: Install from source
266
+ **Option 3:** Install from source (developer setup)
266
267
 
267
268
  ```bash
268
269
  git clone https://github.com/SWE-agent/mini-swe-agent.git
269
- cd mini-swe-agent
270
- pip install -e .
271
- mini [-v]
270
+ cd mini-swe-agent && pip install -e .
271
+ mini [-v] # run the CLI
272
272
  ```
273
273
 
274
274
  Read more in our [documentation](https://mini-swe-agent.com/latest/):
@@ -298,14 +298,15 @@ If you found this work helpful, please consider citing the [SWE-agent paper](htt
298
298
  Our other projects:
299
299
 
300
300
  <div align="center">
301
- <a href="https://github.com/SWE-agent/SWE-agent"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/sweagent_logo_text_below.svg" alt="SWE-agent" height="120px"></a>
301
+ <a href="https://github.com/SWE-agent/SWE-agent"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/sweagent_logo_text_below.svg" alt="SWE-agent" height="120px"></a>
302
302
  &nbsp;&nbsp;
303
- <a href="https://github.com/SWE-agent/SWE-ReX"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swerex_logo_text_below.svg" alt="SWE-ReX" height="120px"></a>
303
+ <a href="https://github.com/SWE-agent/SWE-ReX"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swerex_logo_text_below.svg" alt="SWE-ReX" height="120px"></a>
304
304
  &nbsp;&nbsp;
305
- <a href="https://github.com/SWE-bench/SWE-bench"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swebench_logo_text_below.svg" alt="SWE-bench" height="120px"></a>
305
+ <a href="https://github.com/SWE-bench/SWE-bench"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swebench_logo_text_below.svg" alt="SWE-bench" height="120px"></a>
306
306
  &nbsp;&nbsp;
307
- <a href="https://github.com/SWE-bench/SWE-smith"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/swesmith_logo_text_below.svg" alt="SWE-smith" height="120px"></a>
307
+ <a href="https://github.com/SWE-bench/SWE-smith"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/swesmith_logo_text_below.svg" alt="SWE-smith" height="120px"></a>
308
308
  &nbsp;&nbsp;
309
- <a href="https://github.com/SWE-bench/sb-cli"><img src="https://github.com/SWE-agent/mini-swe-agent/raw/main/docs/assets/sbcli_logo_text_below.svg" alt="sb-cli" height="120px"></a>
309
+ <a href="https://github.com/codeclash-ai/codeclash"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/codeclash_logo_text_below.svg" alt="CodeClash" height="120px"></a>
310
+ &nbsp;&nbsp;
311
+ <a href="https://github.com/SWE-bench/sb-cli"><img src="https://raw.githubusercontent.com/SWE-agent/swe-agent-media/refs/heads/main/media/logos_banners/sbcli_logo_text_below.svg" alt="sb-cli" height="120px"></a>
310
312
  </div>
311
-
@@ -8,7 +8,7 @@ This file provides:
8
8
  unless you want the static type checking.
9
9
  """
10
10
 
11
- __version__ = "1.14.4"
11
+ __version__ = "1.15.0"
12
12
 
13
13
  import os
14
14
  from pathlib import Path
@@ -27,6 +27,8 @@ class LitellmModelConfig:
27
27
  litellm_model_registry: Path | str | None = os.getenv("LITELLM_MODEL_REGISTRY_PATH")
28
28
  set_cache_control: Literal["default_end"] | None = None
29
29
  """Set explicit cache control markers, for example for Anthropic models"""
30
+ cost_tracking: Literal["default", "ignore_errors"] = os.getenv("MSWEA_COST_TRACKING", "default")
31
+ """Cost tracking mode for this model. Can be "default" or "ignore_errors" (ignore errors/missing cost info)"""
30
32
 
31
33
 
32
34
  class LitellmModel:
@@ -68,15 +70,22 @@ class LitellmModel:
68
70
  response = self._query(messages, **kwargs)
69
71
  try:
70
72
  cost = litellm.cost_calculator.completion_cost(response)
73
+ if cost <= 0.0:
74
+ raise ValueError(f"Cost must be > 0.0, got {cost}")
71
75
  except Exception as e:
72
- logger.critical(
73
- f"Error calculating cost for model {self.config.model_name}: {e}. "
74
- "Please check the 'Updating the model registry' section in the documentation at "
75
- "https://klieret.short.gy/litellm-model-registry Still stuck? Please open a github issue for help!"
76
- )
77
- raise
76
+ cost = 0.0
77
+ if self.config.cost_tracking != "ignore_errors":
78
+ msg = (
79
+ f"Error calculating cost for model {self.config.model_name}: {e}, perhaps it's not registered? "
80
+ "You can ignore this issue from your config file with cost_tracking: 'ignore_errors' or "
81
+ "globally with export MSWEA_COST_TRACKING='ignore_errors'. "
82
+ "Alternatively check the 'Cost tracking' section in the documentation at "
83
+ "https://klieret.short.gy/mini-local-models. "
84
+ " Still stuck? Please open a github issue at https://github.com/SWE-agent/mini-swe-agent/issues/new/choose!"
85
+ )
86
+ logger.critical(msg)
87
+ raise RuntimeError(msg) from e
78
88
  self.n_calls += 1
79
- assert cost >= 0.0, f"Cost is negative: {cost}"
80
89
  self.cost += cost
81
90
  GLOBAL_MODEL_STATS.add(cost)
82
91
  return {
@@ -25,6 +25,8 @@ class OpenRouterModelConfig:
25
25
  model_kwargs: dict[str, Any] = field(default_factory=dict)
26
26
  set_cache_control: Literal["default_end"] | None = None
27
27
  """Set explicit cache control markers, for example for Anthropic models"""
28
+ cost_tracking: Literal["default", "ignore_errors"] = os.getenv("MSWEA_COST_TRACKING", "default")
29
+ """Cost tracking mode for this model. Can be "default" or "ignore_errors" (ignore errors/missing cost info)"""
28
30
 
29
31
 
30
32
  class OpenRouterAPIError(Exception):
@@ -97,16 +99,15 @@ class OpenRouterModel:
97
99
  messages = set_cache_control(messages, mode=self.config.set_cache_control)
98
100
  response = self._query(messages, **kwargs)
99
101
 
100
- # Extract cost from usage information
101
102
  usage = response.get("usage", {})
102
103
  cost = usage.get("cost", 0.0)
103
- assert cost >= 0.0, f"Cost is negative: {cost}"
104
-
105
- # If total_cost is not available, raise an error
106
- if cost == 0.0:
107
- raise OpenRouterAPIError(
108
- f"No cost information available from OpenRouter API for model {self.config.model_name}. "
109
- "Cost tracking is required but not provided by the API response."
104
+ if cost <= 0.0 and self.config.cost_tracking != "ignore_errors":
105
+ raise RuntimeError(
106
+ f"No valid cost information available from OpenRouter API for model {self.config.model_name}: "
107
+ f"Usage {usage}, cost {cost}. Cost must be > 0.0. Set cost_tracking: 'ignore_errors' in your config file or "
108
+ "export MSWEA_COST_TRACKING='ignore_errors' to ignore cost tracking errors "
109
+ "(for example for free/local models), more information at https://klieret.short.gy/mini-local-models "
110
+ "for more details. Still stuck? Please open a github issue at https://github.com/SWE-agent/mini-swe-agent/issues/new/choose!"
110
111
  )
111
112
 
112
113
  self.n_calls += 1
@@ -40,6 +40,8 @@ class PortkeyModelConfig:
40
40
  """
41
41
  set_cache_control: Literal["default_end"] | None = None
42
42
  """Set explicit cache control markers, for example for Anthropic models"""
43
+ cost_tracking: Literal["default", "ignore_errors"] = os.getenv("MSWEA_COST_TRACKING", "default")
44
+ """Cost tracking mode for this model. Can be "default" or "ignore_errors" (ignore errors/missing cost info)"""
43
45
 
44
46
 
45
47
  class PortkeyModel:
@@ -91,6 +93,22 @@ class PortkeyModel:
91
93
  if self.config.set_cache_control:
92
94
  messages = set_cache_control(messages, mode=self.config.set_cache_control)
93
95
  response = self._query(messages, **kwargs)
96
+ cost = self._calculate_cost(response)
97
+ self.n_calls += 1
98
+ self.cost += cost
99
+ GLOBAL_MODEL_STATS.add(cost)
100
+ return {
101
+ "content": response.choices[0].message.content or "",
102
+ "extra": {
103
+ "response": response.model_dump(),
104
+ "cost": cost,
105
+ },
106
+ }
107
+
108
+ def get_template_vars(self) -> dict[str, Any]:
109
+ return asdict(self.config) | {"n_model_calls": self.n_calls, "model_cost": self.cost}
110
+
111
+ def _calculate_cost(self, response) -> float:
94
112
  response_for_cost_calc = response.model_copy()
95
113
  if self.config.litellm_model_name_override:
96
114
  if response_for_cost_calc.model:
@@ -114,33 +132,25 @@ class PortkeyModel:
114
132
  f"WARNING: Total tokens - prompt tokens - completion tokens != 0: {response_for_cost_calc.model_dump()}."
115
133
  " This is probably a portkey bug or incompatibility with litellm cost tracking. "
116
134
  "Setting prompt tokens based on total tokens and completion tokens. You might want to double check your costs. "
117
- "Full response: {response_for_cost_calc.model_dump()}"
135
+ f"Full response: {response_for_cost_calc.model_dump()}"
118
136
  )
119
137
  response_for_cost_calc.usage.prompt_tokens = total_tokens - completion_tokens
120
138
  try:
121
139
  cost = litellm.cost_calculator.completion_cost(
122
140
  response_for_cost_calc, model=self.config.litellm_model_name_override or None
123
141
  )
142
+ assert cost >= 0.0, f"Cost is negative: {cost}"
124
143
  except Exception as e:
125
- logger.critical(
126
- f"Error calculating cost for model {self.config.model_name} based on {response_for_cost_calc.model_dump()}: {e}. "
127
- "Please check the 'Updating the model registry' section in the documentation at "
128
- "https://klieret.short.gy/litellm-model-registry Still stuck? Please open a github issue for help!"
129
- )
130
- raise
131
- assert cost >= 0.0, f"Cost is negative: {cost}"
132
-
133
- self.n_calls += 1
134
- self.cost += cost
135
- GLOBAL_MODEL_STATS.add(cost)
136
-
137
- return {
138
- "content": response.choices[0].message.content or "",
139
- "extra": {
140
- "response": response.model_dump(),
141
- "cost": cost,
142
- },
143
- }
144
-
145
- def get_template_vars(self) -> dict[str, Any]:
146
- return asdict(self.config) | {"n_model_calls": self.n_calls, "model_cost": self.cost}
144
+ cost = 0.0
145
+ if self.config.cost_tracking != "ignore_errors":
146
+ msg = (
147
+ f"Error calculating cost for model {self.config.model_name} based on {response_for_cost_calc.model_dump()}: {e}. "
148
+ "You can ignore this issue from your config file with cost_tracking: 'ignore_errors' or "
149
+ "globally with export MSWEA_COST_TRACKING='ignore_errors' to ignore this error. "
150
+ "Alternatively check the 'Cost tracking' section in the documentation at "
151
+ "https://klieret.short.gy/mini-local-models. "
152
+ "Still stuck? Please open a github issue at https://github.com/SWE-agent/mini-swe-agent/issues/new/choose!"
153
+ )
154
+ logger.critical(msg)
155
+ raise RuntimeError(msg) from e
156
+ return cost
@@ -100,8 +100,7 @@ def main(
100
100
  exit_status, result = type(e).__name__, str(e)
101
101
  extra_info = {"traceback": traceback.format_exc()}
102
102
  finally:
103
- if output:
104
- save_traj(agent, output, exit_status=exit_status, result=result, extra_info=extra_info) # type: ignore[arg-type]
103
+ save_traj(agent, output, exit_status=exit_status, result=result, extra_info=extra_info) # type: ignore[arg-type]
105
104
  return agent
106
105
 
107
106
 
@@ -21,7 +21,7 @@ def _asdict(obj: Any) -> dict:
21
21
 
22
22
  def save_traj(
23
23
  agent: Agent | None,
24
- path: Path,
24
+ path: Path | None,
25
25
  *,
26
26
  print_path: bool = True,
27
27
  exit_status: str | None = None,
@@ -42,6 +42,8 @@ def save_traj(
42
42
  **kwargs: Additional information to save (will be merged into top level)
43
43
 
44
44
  """
45
+ if path is None:
46
+ return
45
47
  data = {
46
48
  "info": {
47
49
  "exit_status": exit_status,