SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Fix: Ensure that the right fields are part of demo
Kilian Lieret6496dddd887a
diff --git a/sweagent/run/run_traj_to_demo.py b/sweagent/run/run_traj_to_demo.pyindex a62dde52..1ae6d5b2 100644--- a/sweagent/run/run_traj_to_demo.py+++ b/sweagent/run/run_traj_to_demo.py@@ -66,9 +66,11 @@ def convert_traj_to_action_demo(traj_path: Path, output_file: Path, include_userreplay_config = traj["replay_config"]history = traj["history"]+ copy_fields = {"content", "role", "tool_calls", "agent", "message_type", "tool_call_ids"}+admissible_roles = {"assistant", "user", "tool"} if include_user else {"assistant"}filtered_history = [- {k: v for k, v in step.items() if k in {"content", "role", "tool_calls"}}+ {k: v for k, v in step.items() if k in copy_fields}for step in historyif step["role"] in admissible_rolesand step.get("agent", "main") in {"main", "primary"}diff --git a/trajectories/demonstrations/str_replace_anthropic_demo.yaml b/trajectories/demonstrations/str_replace_anthropic_demo.yamlindex 5b62a8f9..7caa6955 100644--- a/trajectories/demonstrations/str_replace_anthropic_demo.yaml+++ b/trajectories/demonstrations/str_replace_anthropic_demo.yaml@@ -43,14 +43,18 @@ history:(Open file: )(Current directory: )bash-$+ agent: main+ message_type: observation- role: assistantcontent: Let’s start by exploring the repository structure.+ agent: maintool_calls:- function:arguments: '{"command":"view","path":"/swe-agent-test-repo"}'name: str_replace_editorid: call_ggIm89M8rcBQorveMgkIrL7Gtype: function+ message_type: action- role: toolcontent: |-Here's the files and directories up to 2 levels deep in /swe-agent-test-repo, excluding hidden items:@@ -71,14 +75,20 @@ history:(Open file: )(Current directory: )bash-$+ agent: main+ message_type: observation+ tool_call_ids:+ - call_ggIm89M8rcBQorveMgkIrL7G- role: assistantcontent: We have several Python files in the repository. `missing_colon.py` is directly mentioned in the PR description, so let's open it.+ agent: maintool_calls:- function:arguments: '{"command":"view","path":"/swe-agent-test-repo/src/testpkg/missing_colon.py"}'name: str_replace_editorid: call_QbSqph4VzA951X9eMEgsvyOmtype: function+ message_type: action- role: toolcontent: |-Here's the result of running `cat -n` on /swe-agent-test-repo/src/testpkg/missing_colon.py:@@ -96,14 +106,20 @@ history:(Open file: )(Current directory: )bash-$+ agent: main+ message_type: observation+ tool_call_ids:+ - call_QbSqph4VzA951X9eMEgsvyOm- role: assistantcontent: We can see that the file contains a missing colon. Let's fix it by replacing the line with the correct version.+ agent: maintool_calls:- function:arguments: '{"command":"str_replace","path":"/swe-agent-test-repo/src/testpkg/missing_colon.py","old_str":"def division(a: float, b: float) -> float","new_str":"def division(a: float, b: float) -> float:"}'name: str_replace_editorid: call_QgE1MNhZQ2W66DgwRZGXEo1Dtype: function+ message_type: action- role: toolcontent: |-The file /swe-agent-test-repo/src/testpkg/missing_colon.py has been edited. Here's the result of running `cat -n` on a snippet of /swe-agent-test-repo/src/testpkg/missing_colon.py:@@ -119,16 +135,22 @@ history:(Open file: )(Current directory: )bash-$+ agent: main+ message_type: observation+ tool_call_ids:+ - call_QgE1MNhZQ2W66DgwRZGXEo1D- role: assistantcontent: The missing colon has been fixed. The change should not break any existing functionality. Let's submit the changes.+ agent: maintool_calls:- function:arguments: '{}'name: submitid: call_zyAyd9wbLeSeRaFXrKwlQYwItype: function+ message_type: action- role: tool- content: |-+ content: |2-diff --git a/src/testpkg/missing_colon.py b/src/testpkg/missing_colon.pyindex 20edef5..5857437 100755@@ -147,6 +169,10 @@ history:(Open file: )(Current directory: )bash-$+ agent: main+ message_type: observation+ tool_call_ids:+ - call_zyAyd9wbLeSeRaFXrKwlQYwIreplay_config:env:deployment: