You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`stderr=subprocess.STDOUT`- Redirects stderr to stdout (so we capture both in one stream)
348
349
-`timeout=30`: Stop executing after
349
350
350
-
Let's put it together and run it!
351
+
There are a couple of limitations to this:
352
+
353
+
1. The agent will not be able to `cd` to a different environment
354
+
2. The agent cannot persist environment variables easily
355
+
356
+
However, in practice, we have found these limitations to be not very limiting at all.
357
+
In fact, reducing the amount of hidden state and forcing the agent to work with absolute paths might well be helpful for language models in many instances.
351
358
352
359
### Add a system prompt
353
360
@@ -409,11 +416,12 @@ messages = [{
409
416
410
417
The following sections are some tweaks to improve performance.
411
418
Nothing fancy, just making sure that the agent doesn't get stuck and can deal with things that go wrong.
412
-
This section is a bit more advanced compared to the last one
419
+
This section is a bit more advanced.
420
+
Instead of showing the complete code at the end, we encourage everyone to check out the [source code](https://github.com/SWE-agent/mini-swe-agent/) of our `mini` agent; it includes all of these features with very little fluff around it (also see the next section to get started with reading the code).
413
421
414
422
### Dealing with exceptions in the control flow
415
423
416
-
The biggest idea here: Whenever a known exception arises, let's just tell the LM itself and let it handle it. This means adapting our `while` loop a bit:
424
+
The idea here: Whenever a known exception arises (timeouts, format errors, etc.), let's just tell the LM and let it handle it itself. This means adapting our `while` loop a bit:
417
425
418
426
```python
419
427
whileTrue:
@@ -424,8 +432,8 @@ while True:
424
432
```
425
433
426
434
That's it!
427
-
Now imagine the agent does something stupid (like calling `vim`) and a `TimeoutError`is triggered.
428
-
No problem, this will just cause the error message to be appended to the messages and the
435
+
436
+
For example, if the agent does something stupid (like calling `vim`) and a `TimeoutError`is triggered, this will cause the error message to be appended to the messages and the
429
437
LM can pick up from there, hopefully realizing what it did wrong.
430
438
431
439
However, we might only limit this behavior to some known problems or add more information to the message. In this case, we can be more specific, for example
@@ -562,27 +570,36 @@ class Environment:
562
570
```
563
571
564
572
`mini-swe-agent` provides different environment classes that for example allow to execute actions in docker containers instead of directly in your local environment.
573
+
Sonds more complicated? It really isn't: all we do is switch from `subprocess.run` to calls to `docker exec`.
565
574
566
575
<h2 id="contribute">Contribute to this guide</h2>
567
576
568
-
We welcome contributions to improve this guide!
569
-
Particularly, the following is very appreciated right now:
577
+
We welcome contributions on GitHub to improve this guide!
578
+
579
+
??? Contribution guidelines
580
+
581
+
The following PRs will be merged immediately
582
+
583
+
- Bug fixes
584
+
- Typo fixes
585
+
586
+
The following PRs are much appreciated and will most likely be merged fast:
587
+
588
+
- Adding support to popular LMs that aren't mentioned yet (please make sure test your implementation)
570
589
571
-
- Bug fixes
572
-
- Typo fixes
573
-
- Adding support to popular LMs that aren't mentioned yet
590
+
The following things should be discussed first (via github issue):
574
591
575
-
The following things should be discussed first (via github issue)
592
+
- Additional sections
593
+
- Significant expansions of sections
576
594
577
-
- Additional sections
578
-
- Significant expansions of sections
595
+
Please understand that the larger your changes are, the more time we will need to review and the less likely it is we can accept them (unless we discussed beforehand).
579
596
580
-
Please understand that the larger your changes are, the more time we will need to review and the less likely it is we can accept them (unless we discussed beforehand).
597
+
To contribute:
581
598
582
-
To contribute:
599
+
- Fork the repository
600
+
- Make your changes
601
+
- Submit a pull request
583
602
584
-
- Fork the repository
585
-
- Make your changes
586
-
- Submit a pull request
603
+
You can find the source code on GitHub.
587
604
588
-
You can find the source code on GitHub.
605
+
If you have questions or comments, please comment below. Note that GitHub issues are still preferred for bug reports and discussions about further developing this page.
0 commit comments