Skip to content

Commit 985e20d

Browse files
authored
[chore] Run full agent pre-commit (All-Hands-AI#8235)
1 parent 98cb2e2 commit 985e20d

File tree

27 files changed

+186
-147
lines changed

27 files changed

+186
-147
lines changed

docs/modules/usage/mcp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ MCP configuration is defined in the `[mcp]` section of your `config.toml` file.
2020
sse_servers = [
2121
# Basic SSE server with just a URL
2222
"http://example.com:8080/mcp",
23-
23+
2424
# SSE server with API key authentication
2525
{url="https://secure-example.com/mcp", api_key="your-api-key"}
2626
]
@@ -29,7 +29,7 @@ sse_servers = [
2929
stdio_servers = [
3030
# Basic stdio server
3131
{name="fetch", command="uvx", args=["mcp-server-fetch"]},
32-
32+
3333
# Stdio server with environment variables
3434
{
3535
name="data-processor",

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@
5555
"node": ">=18.0"
5656
},
5757
"packageManager": "[email protected]"
58-
}
58+
}

evaluation/benchmarks/multi_swe_bench/run_infer.py

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@
3636
)
3737
from openhands.core.logger import openhands_logger as logger
3838
from openhands.core.main import create_runtime, run_controller
39-
from openhands.events.action import CmdRunAction, MessageAction, FileReadAction
39+
from openhands.events.action import CmdRunAction, FileReadAction, MessageAction
4040
from openhands.events.observation import CmdOutputObservation, ErrorObservation
4141
from openhands.events.serialization.event import event_to_dict
4242
from openhands.runtime.base import Runtime
4343
from openhands.utils.async_utils import call_async_from_sync
4444
from openhands.utils.shutdown_listener import sleep_if_should_continue
45-
import pdb
4645

4746
USE_HINT_TEXT = os.environ.get('USE_HINT_TEXT', 'false').lower() == 'true'
4847
USE_INSTANCE_IMAGE = os.environ.get('USE_INSTANCE_IMAGE', 'true').lower() == 'true'
@@ -51,7 +50,7 @@
5150
# TODO: migrate all swe-bench docker to ghcr.io/openhands
5251
# TODO: 适应所有的语言
5352
DOCKER_IMAGE_PREFIX = os.environ.get('EVAL_DOCKER_IMAGE_PREFIX', '')
54-
LANGUAGE =os.environ.get('LANGUAGE', 'python')
53+
LANGUAGE = os.environ.get('LANGUAGE', 'python')
5554
logger.info(f'Using docker image prefix: {DOCKER_IMAGE_PREFIX}')
5655

5756

@@ -71,7 +70,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
7170
# Instruction based on Anthropic's official trajectory
7271
# https://github.com/eschluntz/swe-bench-experiments/tree/main/evaluation/verified/20241022_tools_claude-3-5-sonnet-updated/trajs
7372
instructions = {
74-
"python":(
73+
'python': (
7574
'<uploaded_files>\n'
7675
f'/workspace/{workspace_dir_name}\n'
7776
'</uploaded_files>\n'
@@ -96,7 +95,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
9695
' Make sure all these tests pass with your changes.\n'
9796
"Your thinking should be thorough and so it's fine if it's very long.\n"
9897
),
99-
"java": (
98+
'java': (
10099
'<uploaded_files>\n'
101100
f'/workspace/{workspace_dir_name}\n'
102101
'</uploaded_files>\n'
@@ -121,7 +120,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
121120
" Make sure all these tests pass with your changes.\n"
122121
"Your thinking should be thorough and so it's fine if it's very long.\n"
123122
),
124-
"go": (
123+
'go': (
125124
'<uploaded_files>\n'
126125
f'/workspace/{workspace_dir_name}\n'
127126
'</uploaded_files>\n'
@@ -146,7 +145,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
146145
' Make sure all these tests pass with your changes.\n'
147146
"Your thinking should be thorough and so it's fine if it's very long.\n"
148147
),
149-
"c": (
148+
'c': (
150149
'<uploaded_files>\n'
151150
f'/workspace/{workspace_dir_name}\n'
152151
'</uploaded_files>\n'
@@ -171,7 +170,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
171170
' Make sure all these tests pass with your changes.\n'
172171
"Your thinking should be thorough and so it's fine if it's very long.\n"
173172
),
174-
"cpp": (
173+
'cpp': (
175174
'<uploaded_files>\n'
176175
f'/workspace/{workspace_dir_name}\n'
177176
'</uploaded_files>\n'
@@ -196,7 +195,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
196195
' Make sure all these tests pass with your changes.\n'
197196
"Your thinking should be thorough and so it's fine if it's very long.\n"
198197
),
199-
"javascript": (
198+
'javascript': (
200199
'<uploaded_files>\n'
201200
f'/workspace/{workspace_dir_name}\n'
202201
'</uploaded_files>\n'
@@ -221,7 +220,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
221220
' Make sure all these tests pass with your changes.\n'
222221
"Your thinking should be thorough and so it's fine if it's very long.\n"
223222
),
224-
"typescript":(
223+
'typescript': (
225224
'<uploaded_files>\n'
226225
f'/workspace/{workspace_dir_name}\n'
227226
'</uploaded_files>\n'
@@ -246,7 +245,7 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
246245
' Make sure all these tests pass with your changes.\n'
247246
"Your thinking should be thorough and so it's fine if it's very long.\n"
248247
),
249-
"rust":(
248+
'rust': (
250249
'<uploaded_files>\n'
251250
f'/workspace/{workspace_dir_name}\n'
252251
'</uploaded_files>\n'
@@ -270,11 +269,10 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
270269
' - The functions you changed\n'
271270
' Make sure all these tests pass with your changes.\n'
272271
"Your thinking should be thorough and so it's fine if it's very long.\n"
273-
)
272+
),
274273
}
275274
instruction = instructions.get(LANGUAGE.lower())
276275

277-
278276
if instruction and RUN_WITH_BROWSING:
279277
instruction += (
280278
'<IMPORTANT!>\n'
@@ -284,7 +282,6 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata):
284282
return instruction
285283

286284

287-
288285
# TODO: 适应所有的语言
289286
# def get_instance_docker_image(instance_id: str) -> str:
290287
# image_name = 'sweb.eval.x86_64.' + instance_id
@@ -307,16 +304,15 @@ def get_instance_docker_image(instance: pd.Series):
307304
container_name = container_name.replace('/', '_m_')
308305
instance_id = instance.get('instance_id', '')
309306
tag_suffix = instance_id.split('-')[-1] if instance_id else ''
310-
container_tag = f"pr-{tag_suffix}"
307+
container_tag = f'pr-{tag_suffix}'
311308
# pdb.set_trace()
312-
return f"mswebench/{container_name}:{container_tag}"
309+
return f'mswebench/{container_name}:{container_tag}'
313310
# return "kong/insomnia:pr-8284"
314311
# return "'sweb.eval.x86_64.local_insomnia"
315312
# return "local_insomnia_why"
316313
# return "local/kong-insomnia:pr-8117"
317314

318315

319-
320316
def get_config(
321317
instance: pd.Series,
322318
metadata: EvalMetadata,
@@ -569,7 +565,6 @@ def complete_runtime(
569565
f'Failed to git config --global core.pager "": {str(obs)}',
570566
)
571567

572-
573568
action = CmdRunAction(command='git add -A')
574569
action.set_hard_timeout(600)
575570
logger.info(action, extra={'msg_type': 'ACTION'})
@@ -582,14 +577,14 @@ def complete_runtime(
582577

583578
##删除二进制文件
584579
action = CmdRunAction(
585-
command=f'''
580+
command="""
586581
for file in $(git status --porcelain | grep -E "^(M| M|\\?\\?|A| A)" | cut -c4-); do
587582
if [ -f "$file" ] && (file "$file" | grep -q "executable" || git check-attr binary "$file" | grep -q "binary: set"); then
588583
git rm -f "$file" 2>/dev/null || rm -f "$file"
589584
echo "Removed: $file"
590585
fi
591586
done
592-
'''
587+
"""
593588
)
594589
action.set_hard_timeout(600)
595590
logger.info(action, extra={'msg_type': 'ACTION'})
@@ -626,14 +621,12 @@ def complete_runtime(
626621
else:
627622
assert_and_raise(False, f'Unexpected observation type: {str(obs)}')
628623

629-
action = FileReadAction(
630-
path='patch.diff'
631-
)
624+
action = FileReadAction(path='patch.diff')
632625
action.set_hard_timeout(max(300 + 100 * n_retries, 600))
633626
logger.info(action, extra={'msg_type': 'ACTION'})
634627
obs = runtime.run_action(action)
635628
git_patch = obs.content
636-
# pdb.set_trace()
629+
# pdb.set_trace()
637630

638631
assert_and_raise(git_patch is not None, 'Failed to get git diff (None)')
639632

@@ -714,20 +707,21 @@ def remove_binary_diffs(patch_text):
714707
is_binary_block = False
715708

716709
for line in lines:
717-
if line.startswith("diff --git "):
710+
if line.startswith('diff --git '):
718711
if block and not is_binary_block:
719712
cleaned_lines.extend(block)
720713
block = [line]
721714
is_binary_block = False
722-
elif "Binary files" in line:
715+
elif 'Binary files' in line:
723716
is_binary_block = True
724717
block.append(line)
725718
else:
726719
block.append(line)
727720

728721
if block and not is_binary_block:
729722
cleaned_lines.extend(block)
730-
return "\n".join(cleaned_lines)
723+
return '\n'.join(cleaned_lines)
724+
731725
git_patch = remove_binary_diffs(git_patch)
732726
test_result = {
733727
'git_patch': git_patch,
@@ -797,7 +791,7 @@ def filter_dataset(dataset: pd.DataFrame, filter_column: str) -> pd.DataFrame:
797791
# so we don't need to manage file uploading to OpenHands's repo
798792
# dataset = load_dataset(args.dataset, split=args.split)
799793
# dataset = load_dataset(args.dataset)
800-
dataset = load_dataset("json", data_files = args.dataset)
794+
dataset = load_dataset('json', data_files=args.dataset)
801795
dataset = dataset[args.split]
802796
swe_bench_tests = filter_dataset(dataset.to_pandas(), 'instance_id')
803797
logger.info(

evaluation/benchmarks/multi_swe_bench/scripts/data/data_change.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
input_file = 'XXX.jsonl'
44
output_file = 'YYY.jsonl'
55

6-
with open(input_file, 'r', encoding='utf-8') as fin, open(output_file, 'w', encoding='utf-8') as fout:
6+
with open(input_file, 'r', encoding='utf-8') as fin, open(
7+
output_file, 'w', encoding='utf-8'
8+
) as fout:
79
for line in fin:
810
line = line.strip()
911
if not line:
@@ -13,18 +15,22 @@
1315
item = data
1416

1517
# 提取原始数据
16-
org = item.get("org", "")
17-
repo = item.get("repo", "")
18-
number = str(item.get("number", ""))
18+
org = item.get('org', '')
19+
repo = item.get('repo', '')
20+
number = str(item.get('number', ''))
1921

2022
new_item = {}
21-
new_item["repo"] = f"{org}/{repo}"
22-
new_item["instance_id"] = f"{org}__{repo}-{number}"
23-
new_item["problem_statement"] = item["resolved_issues"][0].get("title", "") + "\n" + item["resolved_issues"][0].get("body", "")
24-
new_item["FAIL_TO_PASS"] = []
25-
new_item["PASS_TO_PASS"] = []
26-
new_item["base_commit"] = item['base'].get("sha","")
27-
new_item["version"] = "0.1" # depends
23+
new_item['repo'] = f'{org}/{repo}'
24+
new_item['instance_id'] = f'{org}__{repo}-{number}'
25+
new_item['problem_statement'] = (
26+
item['resolved_issues'][0].get('title', '')
27+
+ '\n'
28+
+ item['resolved_issues'][0].get('body', '')
29+
)
30+
new_item['FAIL_TO_PASS'] = []
31+
new_item['PASS_TO_PASS'] = []
32+
new_item['base_commit'] = item['base'].get('sha', '')
33+
new_item['version'] = '0.1' # depends
2834

2935
output_data = new_item
30-
fout.write(json.dumps(output_data, ensure_ascii=False) + "\n")
36+
fout.write(json.dumps(output_data, ensure_ascii=False) + '\n')

evaluation/benchmarks/multi_swe_bench/scripts/eval/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def main():
1515
'org': groups.group(1),
1616
'repo': groups.group(2),
1717
'number': groups.group(3),
18-
'fix_patch': data['test_result']['git_patch']
18+
'fix_patch': data['test_result']['git_patch'],
1919
}
2020
fout.write(json.dumps(patch) + '\n')
2121

frontend/__tests__/components/features/auth-modal.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("AuthModal", () => {
2727

2828
it("should render the GitHub and GitLab buttons", () => {
2929
render(<AuthModal githubAuthUrl="mock-url" appMode="saas" />);
30-
30+
3131
const githubButton = screen.getByRole("button", { name: "GITHUB$CONNECT_TO_GITHUB" });
3232
const gitlabButton = screen.getByRole("button", { name: "GITLAB$CONNECT_TO_GITLAB" });
3333

frontend/__tests__/routes/accept-tos.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const createWrapper = () => {
4343
},
4444
},
4545
});
46-
46+
4747
return ({ children }: { children: React.ReactNode }) => (
4848
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
4949
);
@@ -61,7 +61,7 @@ describe("AcceptTOS", () => {
6161

6262
it("should render a TOS checkbox that is unchecked by default", () => {
6363
render(<AcceptTOS />, { wrapper: createWrapper() });
64-
64+
6565
const checkbox = screen.getByRole("checkbox");
6666
const continueButton = screen.getByRole("button", { name: "TOS$CONTINUE" });
6767

@@ -72,7 +72,7 @@ describe("AcceptTOS", () => {
7272
it("should enable the continue button when the TOS checkbox is checked", async () => {
7373
const user = userEvent.setup();
7474
render(<AcceptTOS />, { wrapper: createWrapper() });
75-
75+
7676
const checkbox = screen.getByRole("checkbox");
7777
const continueButton = screen.getByRole("button", { name: "TOS$CONTINUE" });
7878

@@ -96,7 +96,7 @@ describe("AcceptTOS", () => {
9696

9797
const user = userEvent.setup();
9898
render(<AcceptTOS />, { wrapper: createWrapper() });
99-
99+
100100
const checkbox = screen.getByRole("checkbox");
101101
await user.click(checkbox);
102102

@@ -121,7 +121,7 @@ describe("AcceptTOS", () => {
121121

122122
const user = userEvent.setup();
123123
render(<AcceptTOS />, { wrapper: createWrapper() });
124-
124+
125125
const checkbox = screen.getByRole("checkbox");
126126
await user.click(checkbox);
127127

@@ -133,4 +133,4 @@ describe("AcceptTOS", () => {
133133

134134
expect(window.location.href).toBe(externalUrl);
135135
});
136-
});
136+
});

openhands/integrations/github/github_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,9 @@ async def get_suggested_tasks(self) -> list[SuggestedTask]:
390390
except Exception:
391391
return []
392392

393-
async def get_repository_details_from_repo_name(self, repository: str) -> Repository:
393+
async def get_repository_details_from_repo_name(
394+
self, repository: str
395+
) -> Repository:
394396
url = f'{self.BASE_URL}/repos/{repository}'
395397
repo, _ = await self._make_request(url)
396398

openhands/integrations/gitlab/gitlab_service.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,10 @@ async def get_suggested_tasks(self) -> list[SuggestedTask]:
382382
except Exception:
383383
return []
384384

385-
386-
async def get_repository_details_from_repo_name(self, repository: str) -> Repository:
387-
encoded_name = repository.replace("/", "%2F")
385+
async def get_repository_details_from_repo_name(
386+
self, repository: str
387+
) -> Repository:
388+
encoded_name = repository.replace('/', '%2F')
388389

389390
url = f'{self.BASE_URL}/projects/{encoded_name}'
390391
repo, _ = await self._make_request(url)
@@ -396,8 +397,6 @@ async def get_repository_details_from_repo_name(self, repository: str) -> Reposi
396397
git_provider=ProviderType.GITLAB,
397398
is_public=repo.get('visibility') == 'public',
398399
)
399-
400-
401400

402401

403402
gitlab_service_cls = os.environ.get(

openhands/integrations/templates/suggested_task/failing_checks_prompt.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Use the {{ apiName }} with the {{ tokenEnvVar }} environment variable to retriev
33
Check out the branch from that {{ requestVerb }} and look at the diff versus the base branch of the {{ requestTypeShort }} to understand the {{ requestTypeShort }}'s intention.
44
Then use the {{ apiName }} to look at the {{ ciSystem }} that are failing on the most recent commit. Try and reproduce the failure locally.
55
Get things working locally, then push your changes. Sleep for 30 seconds at a time until the {{ ciProvider }} {{ ciSystem.lower() }} have run again.
6-
If they are still failing, repeat the process.
6+
If they are still failing, repeat the process.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
You are working on {{ requestType }} #{{ issue_number }} in repository {{ repo }}. You need to fix the merge conflicts.
22
Use the {{ apiName }} with the {{ tokenEnvVar }} environment variable to retrieve the {{ requestTypeShort }} details.
33
Check out the branch from that {{ requestVerb }} and look at the diff versus the base branch of the {{ requestTypeShort }} to understand the {{ requestTypeShort }}'s intention.
4-
Then resolve the merge conflicts. If you aren't sure what the right solution is, look back through the commit history at the commits that introduced the conflict and resolve them accordingly.
4+
Then resolve the merge conflicts. If you aren't sure what the right solution is, look back through the commit history at the commits that introduced the conflict and resolve them accordingly.

0 commit comments

Comments
 (0)