|
49 | 49 | # System Prompt |
50 | 50 | # ───────────────────────────────────────────────────────────────────────────── |
51 | 51 |
|
52 | | -SYSTEM_PROMPT = """Hey, I need you to write some tests for a GitHub PR. |
53 | | -
|
54 | | -The tests are for the SWE-bench benchmark. There are two types: |
55 | | -- fail_to_pass: Tests that FAIL before the PR, but PASS after. These verify the PR works correctly. |
56 | | -- pass_to_pass: Tests that PASS both before and after. These make sure we didnt break anything. |
57 | | -
|
58 | | -Youre running in a Docker container (ubuntu:24.04). First install git and Python: |
59 | | - apt-get update && apt-get install -y python3 python3-pip git |
60 | | -
|
61 | | -Then explore the repo and figure out how to install it. Look at: |
62 | | -- README.md, CONTRIBUTING.md, Makefile |
63 | | -- pyproject.toml, setup.py (Python) |
64 | | -- package.json (JavaScript/TypeScript) |
65 | | -
|
66 | | -When writing tests: |
67 | | -1. Test BEHAVIOR not code. Import the module, call functions, check results. |
68 | | -2. Dont read source files and check if strings exist in them - thats cheating. |
69 | | -3. Use different inputs than shown in the PR to avoid hardcoded solutions. |
70 | | -
|
71 | | -Before submitting: |
72 | | -1. Run the tests to make sure they work |
73 | | -2. Use pytest -c /dev/null test_file.py -v (the -c flag is important) |
74 | | -
|
75 | | -Call submit_tests when done with: fail_to_pass, pass_to_pass, test_files, install_commands |
76 | | -
|
77 | | -Available tools: shell, read_file, write_file, list_dir, grep_files, search_files, submit_tests""" |
| 52 | +SYSTEM_PROMPT = """Write tests for the given PR changes in a Docker container.""" |
78 | 53 |
|
79 | 54 |
|
80 | 55 | # ───────────────────────────────────────────────────────────────────────────── |
@@ -500,25 +475,9 @@ def _truncate(self, s: str, max_len: int = 4000) -> str: |
500 | 475 |
|
501 | 476 | def _build_user_message(self, task: SweTask) -> str: |
502 | 477 | """Build the initial user message for the agent.""" |
503 | | - return f"""Can you write tests for this PR? |
504 | | -
|
505 | | -Repo: {task.repo} |
506 | | -Language: {task.language} |
507 | | -What it does: {self._truncate(task.prompt, 500)} |
508 | | -
|
509 | | -Changes: |
510 | | -``` |
511 | | -{self._truncate(task.patch, 3000)} |
512 | | -``` |
513 | | -
|
514 | | -Steps: |
515 | | -1. Install git/Python: apt-get update && apt-get install -y python3 python3-pip git |
516 | | -2. Look at the repo and install dependencies |
517 | | -3. Write tests for the changes |
518 | | -4. Run your tests |
519 | | -5. Call submit_tests when done |
| 478 | + return f"""Can you add tests for this change in {task.repo}? |
520 | 479 |
|
521 | | -Just use the tools to explore and write tests.""" |
| 480 | +{self._truncate(task.patch, 4000)}""" |
522 | 481 |
|
523 | 482 | def _test_commands_for_language(self, language: str) -> tuple[list[str], list[str]]: |
524 | 483 | """Get suggested build and test commands for a language. |
|
0 commit comments