refactor: update mini_swe_runner to use Hermes built-in backends
Replace all minisweagent imports with Hermes-Agent's own environment classes (LocalEnvironment, DockerEnvironment, ModalEnvironment). mini_swe_runner.py no longer has any dependency on mini-swe-agent. The runner now uses the same backends as the terminal tool, so Docker and Modal environments work out of the box without extra submodules. Tested: local and Docker backends verified working through the runner.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Mini-SWE-Agent Runner with Hermes Trajectory Format
|
||||
SWE Runner with Hermes Trajectory Format
|
||||
|
||||
This module provides a runner that uses mini-swe-agent's execution environments
|
||||
(local, docker, modal) but outputs trajectories in the Hermes-Agent format
|
||||
A runner that uses Hermes-Agent's built-in execution environments
|
||||
(local, docker, modal) and outputs trajectories in the Hermes-Agent format
|
||||
compatible with batch_runner.py and trajectory_compressor.py.
|
||||
|
||||
Features:
|
||||
- Uses mini-swe-agent's Docker, Modal, or Local environments for command execution
|
||||
- Uses Hermes-Agent's Docker, Modal, or Local environments for command execution
|
||||
- Outputs trajectories in Hermes format (from/value pairs with <tool_call>/<tool_response> XML)
|
||||
- Compatible with the trajectory compression pipeline
|
||||
- Supports batch processing from JSONL prompt files
|
||||
@@ -42,13 +42,7 @@ from dotenv import load_dotenv
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
# mini-swe-agent is an optional dependency for this runner.
|
||||
# Install separately: git submodule update --init mini-swe-agent && pip install -e ./mini-swe-agent
|
||||
try:
|
||||
import minisweagent # noqa: F401
|
||||
_HAS_MINISWEAGENT = True
|
||||
except ImportError:
|
||||
_HAS_MINISWEAGENT = False
|
||||
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -112,10 +106,7 @@ def create_environment(
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
Create an execution environment.
|
||||
|
||||
Uses mini-swe-agent environments when available, which requires the
|
||||
mini-swe-agent submodule to be installed separately.
|
||||
Create an execution environment using Hermes-Agent's built-in backends.
|
||||
|
||||
Args:
|
||||
env_type: One of "local", "docker", "modal"
|
||||
@@ -125,25 +116,19 @@ def create_environment(
|
||||
**kwargs: Additional environment-specific options
|
||||
|
||||
Returns:
|
||||
Environment instance with execute() method
|
||||
Environment instance with execute() and cleanup() methods
|
||||
"""
|
||||
if not _HAS_MINISWEAGENT:
|
||||
raise ImportError(
|
||||
"mini-swe-agent is required for mini_swe_runner.py. "
|
||||
"Install it: git submodule update --init mini-swe-agent && pip install -e ./mini-swe-agent"
|
||||
)
|
||||
|
||||
if env_type == "local":
|
||||
from minisweagent.environments.local import LocalEnvironment
|
||||
from tools.environments.local import LocalEnvironment
|
||||
return LocalEnvironment(cwd=cwd, timeout=timeout)
|
||||
|
||||
elif env_type == "docker":
|
||||
from minisweagent.environments.docker import DockerEnvironment
|
||||
from tools.environments.docker import DockerEnvironment
|
||||
return DockerEnvironment(image=image, cwd=cwd, timeout=timeout, **kwargs)
|
||||
|
||||
elif env_type == "modal":
|
||||
from minisweagent.environments.extra.swerex_modal import SwerexModalEnvironment
|
||||
return SwerexModalEnvironment(image=image, cwd=cwd, timeout=timeout, **kwargs)
|
||||
from tools.environments.modal import ModalEnvironment
|
||||
return ModalEnvironment(image=image, cwd=cwd, timeout=timeout, **kwargs)
|
||||
|
||||
else:
|
||||
raise ValueError(f"Unknown environment type: {env_type}. Use 'local', 'docker', or 'modal'")
|
||||
@@ -155,8 +140,8 @@ def create_environment(
|
||||
|
||||
class MiniSWERunner:
|
||||
"""
|
||||
Agent runner that uses mini-swe-agent environments but outputs
|
||||
trajectories in Hermes-Agent format.
|
||||
Agent runner that uses Hermes-Agent's built-in execution environments
|
||||
and outputs trajectories in Hermes-Agent format.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -629,7 +614,7 @@ Complete the user's task step by step."""
|
||||
def main(
|
||||
task: str = None,
|
||||
prompts_file: str = None,
|
||||
output_file: str = "mini-swe-agent-test1.jsonl",
|
||||
output_file: str = "swe-runner-test1.jsonl",
|
||||
model: str = "claude-sonnet-4-20250514",
|
||||
base_url: str = None,
|
||||
api_key: str = None,
|
||||
@@ -641,7 +626,7 @@ def main(
|
||||
verbose: bool = False,
|
||||
):
|
||||
"""
|
||||
Run mini-swe-agent tasks with Hermes trajectory format output.
|
||||
Run SWE tasks with Hermes trajectory format output.
|
||||
|
||||
Args:
|
||||
task: Single task to run (use this OR prompts_file)
|
||||
|
||||
Reference in New Issue
Block a user