Overview of Tools

Since the SWE-Agent-7B and SWE-Agent-32B is trained on the following tools, we only support these tools in the SWE-MiniSandbox framework:

  - path: tools/registry
  - path: tools/edit_anthropic
  - path: tools/submit

Other tools is not ensured to work in the SWE-MiniSandbox framework. However, you can still try to add other tools by yourself. Just follow the instruction in the SWE-agent Configuring tools to add more tools.

The tool path in our project is :

  SWE-agent/
  ├── tools/   # tools for SWE-MiniSandbox
  ├── tool/    # tools for SWE-agent (Same as the original SWE-agent repo)

MiniSandbox Tools

Named tools under the SWE-agent project directory are modified to work in the SWE-MiniSandbox framework. The following tools are supported:

Registry Tool

The Registry Tool is used to manage environment variables for the SWE-Agent. We change its default environment file path to /roots/.swe-agent-env because the root directory is mounted as read-only in the MiniSandbox framework. You can find the modified code in registry.py. You can also specify a custom environment file path by setting the SWE_AGENT_ENV_FILE environment variable.

Edit Anthropic Tool

The Edit Anthropic Tool allows the SWE-Agent to interact with file systems. We change the state path to /roots/state.json here (See in _state_anthropic)

Submit Tool

The Submit Tool is used to submit the task. Original submit script submit directly generates a patch file and echo <<SWE_AGENT_SUBMISSION>> (necessary for detecting submission in SWE-agent). In our implementation, we modify the submit script to only echo <<SWE_AGENT_SUBMISSION>>. The true path generation logic is moved to the MiniSandbox deployment implementation. You can find the implementation here:

swesandbox.sandbox_deployment.SandboxDeployment.get_patch

get_patch(dir='/res.patch')

Get the diff of the current state of the repository.

Source code in sandboxdev/swesandbox/sandbox_deployment.py
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
def get_patch(self,dir='/res.patch') -> str:
    """
    Get the diff of the current state of the repository.
    """
    max_num_tries = 2
    num_tries=0
    for i in range(max_num_tries):
        try:
            output=asyncio.run(self.runtime.run_in_session(BashAction(command=f"cd /{self.git_folder} && git add -A && git diff --cached > {dir}", timeout=60, check='raise'))).output
            break
        except Exception as e:
            num_tries+=1
            self.logger.error(f"Failed to get patch, try {num_tries}/{max_num_tries}: {e}")
            if num_tries==max_num_tries:
                raise e
            asyncio.run(asyncio.sleep(1))
    # output, _ = self.run("git diff")
    return output

Container Tools

We keep the original tools in the SWE-agent/tool/ directory for container deployment. These tools are not modified and work the same way as in the original SWE-agent repository.