Skip to content

Commit 3ffa2e1

Browse files
committed
fix weird descriptions and use new steps for ResolveIssue
1 parent b923a2f commit 3ffa2e1

File tree

3 files changed

+114
-14
lines changed

3 files changed

+114
-14
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ jobs:
158158
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
159159
run: poetry install --no-interaction --only main --extras rag
160160

161-
# disabled because this currently takes too long
162-
# - name: Resolve issue
163-
# run: |
164-
# poetry run patchwork ResolveIssue --log debug \
165-
# --patched_api_key=${{ secrets.PATCHED_API_KEY }} \
166-
# --github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
167-
# --issue_url=https://github.com/patched-codes/patchwork/issues/1039 \
168-
# --disable_telemetry
161+
- name: Resolve issue
162+
run: |
163+
poetry run patchwork ResolveIssue --log debug \
164+
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
165+
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
166+
--issue_url=https://github.com/patched-codes/patchwork/issues/1039 \
167+
--disable_telemetry
168+
--max_llm_calls=10
169169
170170
main-test:
171171
runs-on: ubuntu-latest

patchwork/common/tools/code_edit_tools.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def json_schema(self) -> dict:
2424
* If `path` is a file, `view` displays the result of applying `cat -n`. If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep
2525
* The `create` command cannot be used if the specified `path` already exists as a file
2626
* If a `command` generates a long output, it will be truncated and marked with `<response clipped>`
27-
* The `undo_edit` command will revert the last edit made to the file at `path`
2827
* The working directory is always {self.repo_path}
2928
3029
Notes for using the `str_replace` command:
@@ -36,8 +35,8 @@ def json_schema(self) -> dict:
3635
"properties": {
3736
"command": {
3837
"type": "string",
39-
"enum": ["view", "create", "str_replace", "insert", "undo_edit"],
40-
"description": "The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.",
38+
"enum": ["view", "create", "str_replace", "insert"],
39+
"description": "The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`.",
4140
},
4241
"file_text": {
4342
"description": "Required parameter of `create` command, with the content of the file to be created.",

patchwork/patchflows/ResolveIssue/ResolveIssue.py

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from patchwork.common.utils.progress_bar import PatchflowProgressBar
66
from patchwork.common.utils.step_typing import validate_steps_with_inputs
77
from patchwork.step import Step
8-
from patchwork.steps import PR, FixIssue, ReadIssues
8+
from patchwork.steps import PR, AgenticLLM, FixIssue, ReadIssues, SimplifiedLLMOnce
99

1010
_DEFAULT_INPUT_FILE = Path(__file__).parent / "defaults.yml"
1111

@@ -30,13 +30,114 @@ def __init__(self, inputs: dict):
3030
PR,
3131
)
3232

33+
# currently only support claude
34+
final_inputs["model"] = "claude-3-5-sonnet-latest"
3335
self.inputs = final_inputs
3436

3537
def run(self) -> dict:
3638
outputs = ReadIssues(self.inputs).run()
3739
self.inputs["issue_description"] = outputs
38-
outputs = FixIssue(self.inputs).run()
39-
self.inputs.update(outputs)
40+
41+
outputs = AgenticLLM(
42+
dict(
43+
**self.inputs,
44+
prompt_value=dict(
45+
path=self.inputs.get("base_path", str(Path.cwd())),
46+
issue=outputs["issue_description"],
47+
),
48+
system_prompt="""\
49+
You are a senior software engineer tasked to analyze a issue.
50+
Your analysis will be used to guide the junior engineer to resolve this issue.
51+
""",
52+
user_prompt="""\
53+
<uploaded_files>
54+
{{path}}
55+
</uploaded_files>
56+
I've uploaded a code repository in the current working directory.
57+
58+
Consider the following issue:
59+
60+
<issue_description>
61+
{{issue}}
62+
</issue_description>
63+
64+
Let's first explore and analyze the repository to understand where the issue is located.
65+
Please analyze the repository structure and try to locate the specific files and code sections that need to be modified.
66+
67+
1. First explore the repo structure
68+
2. Identify the relevant files that likely need changes
69+
3. Once you've confirmed the error, identify the specific code sections that need to be modified
70+
71+
Provide your findings in this format:
72+
<analysis>
73+
<files>List the relevant files that need changes</files>
74+
<changes_needed>Description of the specific changes needed</changes_needed>
75+
</analysis>
76+
""",
77+
max_llm_calls=200,
78+
)
79+
).run()
80+
outputs = SimplifiedLLMOnce(
81+
dict(
82+
**self.inputs,
83+
json_schema=dict(
84+
files=["The files to be changed"], changes_needed="Description of the specific changes needed"
85+
),
86+
user_prompt="""\
87+
From the following conversation history extract the following information:
88+
<analysis>
89+
<files>List the relevant files that need changes</files>
90+
<changes_needed>Description of the specific changes needed</changes_needed>
91+
</analysis>
92+
93+
<conversation_history>
94+
{{conversation_history}}
95+
</conversation_history>
96+
""",
97+
prompt_value=outputs,
98+
)
99+
).run()
100+
101+
outputs = AgenticLLM(
102+
dict(
103+
**self.inputs,
104+
prompt_value=dict(
105+
path=self.inputs.get("base_path", str(Path.cwd())),
106+
analysis_result=outputs,
107+
),
108+
system_prompt="""\
109+
You are a senior software engineer assigned to fix an issue. Your lead engineer have already analyzed the issue and provided his analysis for you for reference.
110+
""",
111+
user_prompt="""\
112+
<uploaded_files>
113+
{{path}}
114+
</uploaded_files>
115+
I've uploaded a code repository in the current working directory.
116+
117+
Based on our analysis:
118+
119+
<lead_analysis>
120+
<files_to_be_changed>
121+
{{analysis_result.files}}
122+
</files_to_be_changed>
123+
<change_description>
124+
{{analysis_result.changes_needed}}
125+
</change_description>
126+
</lead_analysis>
127+
128+
Let's implement the necessary changes:
129+
130+
1. Edit the sourcecode of the repo to resolve the issue
131+
2. Think about edge cases and make sure your fix handles them as well
132+
133+
I've already taken care of all changes to any of the test files described in the PR.
134+
This means you DON'T have to modify the testing logic or any of the tests in any way!
135+
""",
136+
max_llm_calls=200,
137+
)
138+
).run()
139+
self.inputs["modified_files"] = outputs["tool_records"]
140+
40141
outputs = PR(self.inputs).run()
41142
self.inputs.update(outputs)
42143

0 commit comments

Comments
 (0)