Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e915ca4
SWE-agent local model WIP commit
ikhillan Oct 7, 2025
3ac817d
Add ollama server startup in swe-agent
jhdavis8 Oct 7, 2025
22600f2
Remove model name from ollama serve command, not needed and in wrong …
jhdavis8 Oct 7, 2025
b2c6af1
WIP w/ adding Klaud's config suggestions
Oct 23, 2025
f426764
Modified .gitignore to include .envrc
ikhillan Oct 23, 2025
9da9146
Cleaned up unnecessary optional SWEAgentTranslator params
ikhillan Oct 23, 2025
3554274
Updated self._swe_agent_model_name initialization in __init__
ikhillan Oct 23, 2025
7ae1977
Add --swe-agent-config to add_args()
ikhillan Oct 23, 2025
8f90863
Delete generated translation_task files
ikhillan Oct 23, 2025
5dcddc6
Updated launch_ollama_server() to mute Ollama startup logs
Oct 28, 2025
1dd87f7
Deleted unnecessary repro_script() function
Oct 28, 2025
9829a6a
Fixed minor style issue
Oct 28, 2025
7d7b08d
Fixed small bug in launch_ollama_server
Oct 28, 2025
be519bc
Change typo for swe-agent-parser choices
Nov 4, 2025
f2a7eb2
Added multi-config file support and vLLM support in SWEAgentTranslator
ikhillan Nov 14, 2025
ab5de16
Fix bugs related to launching vllm server in SWEAgentTranslator
ikhillan Nov 15, 2025
1bf8a37
Fixed small errors w/ vLLM setup for SWE-agent on perlmutter
ikhillan Nov 15, 2025
24a4cd7
Fixed issue w/ removing openai part of model for vllm
ikhillan Nov 15, 2025
53a60f9
WIP Klaud's suggestions
Dec 3, 2025
66e51e5
Made changes w/ Josh and Klaud WIP
Dec 3, 2025
9ffd703
Updated prompt for SWE-agent
Dec 17, 2025
6062bdc
Added temporary Makefile fix
ikhillan Dec 17, 2025
10916b4
Update Makefile fix in SWEAgentTranslator
ikhillan Dec 17, 2025
1372b93
Fix conditional part of fixing Makefiles
ikhillan Dec 17, 2025
5116468
Add ninja dep for Kokkos
jhdavis8 Feb 6, 2026
69fed2e
Codex implementation WIP
ikhillan Mar 3, 2026
82c9552
Modified codex command call
ikhillan Mar 8, 2026
4814d35
WIP fix for codex impl
ikhillan Mar 18, 2026
4e1348f
Added initial OpenCode impl
ikhillan Mar 18, 2026
c4e8fd8
Updated OpenCode Translator to test temperature
ikhillan Mar 22, 2026
3776ed4
Update opencode_config to use tool calling
ikhillan Mar 22, 2026
e369c0c
Modified Codex impl to include vllm_proxy.py helper file
ikhillan Mar 27, 2026
460a629
Used Popen for the codex output logging
ikhillan Mar 27, 2026
53cfb45
Updated OpenCode implementation
ikhillan Apr 7, 2026
a478c7f
Updated codex cmd argument flags
ikhillan Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__

tmp*
.env
.envrc
.venv

.request_cache_*.pkl
Expand Down
85 changes: 76 additions & 9 deletions src/translate/swe_agent/swe_agent_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import subprocess
import json
import time
from typing import List, Optional, Dict, Any

# local imports
Expand All @@ -20,6 +21,7 @@ class SWEAgentTranslator(Translator):
TRAJECTORIES_DIR = "trajectories"
PATCH_FILENAME = "temp.patch"
EXPERIMENT_METADATA_FILENAME = "experiment_metadata.json"
SERVE_CHECK_COOLDOWN = 10

# File extensions to remove from output
REMOVE_EXTENSIONS = (".cu", ".cuh")
Expand All @@ -32,6 +34,10 @@ class SWEAgentTranslator(Translator):
# Instance variables
_swe_agent_model_name: str
_swe_agent_per_instance_cost_limit: float
_swe_agent_config: Optional[str]
_swe_agent_parser: Optional[str]
_swe_agent_max_input_token: Optional[int]

_temp_repo_path: str
_translation_task_path: str
_output_path: str
Expand All @@ -47,7 +53,10 @@ def __init__(
dry: bool = False,
hide_progress: bool = False,
swe_agent_model_name: Optional[str] = None,
swe_agent_per_instance_cost_limit: float = 0.06
swe_agent_per_instance_cost_limit: float = 0.06,
swe_agent_config: Optional[str] = None,
swe_agent_parser: Optional[str] = None,
swe_agent_max_input_token: Optional[int] = None,
) -> None:
super().__init__(
input_repo,
Expand All @@ -62,31 +71,82 @@ def __init__(

self._swe_agent_model_name = swe_agent_model_name
self._swe_agent_per_instance_cost_limit = swe_agent_per_instance_cost_limit
self._swe_agent_config = swe_agent_config
self._swe_agent_parser = swe_agent_parser
self._swe_agent_max_input_token = swe_agent_max_input_token

self._temp_repo_path = self.TEMP_REPO_PATH
self._translation_task_path = os.path.join(
self._input_repo.path, self.TRANSLATION_TASK_FILENAME
)
self._output_path = os.path.join(self._output_paths[0], "repo")

if self._is_ollama_model(self._swe_agent_model_name):
if self._swe_agent_parser is None:
self._swe_agent_parser = "thought_action"
if self._swe_agent_max_input_token is None:
self._swe_agent_max_input_token = 4096
self._launch_ollama_server()

@staticmethod
def _is_ollama_model(name: str) -> bool:
name = (name or "").lower()
return name.startswith("ollama/")


def _launch_ollama_server(self) -> None:
"""Launch an Ollama server in the background."""
# Check that ollama is installed
if not shutil.which("ollama"):
raise ValueError("Ollama is not in the path. Please install Ollama and add it to the path.")
# Early exit if ollama is already running
if subprocess.run(["ollama", "list"], capture_output=True, text=True).returncode == 0:
return
ollama_command = ["ollama", "serve"]
subprocess.Popen(ollama_command,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
stdin=subprocess.DEVNULL,
start_new_session=True,
env=env)
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undefined variable 'env'. The Popen call references 'env' parameter but it is not defined in this function. Either remove the env parameter or define it before use.

Suggested change
start_new_session=True,
env=env)
start_new_session=True)

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation in Popen arguments. The arguments should be consistently indented, and trailing whitespace on lines 108-109 should be removed.

Suggested change
subprocess.Popen(ollama_command,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
stdin=subprocess.DEVNULL,
start_new_session=True,
env=env)
subprocess.Popen(
ollama_command,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
stdin=subprocess.DEVNULL,
start_new_session=True,
env=env
)

Copilot uses AI. Check for mistakes.
# Check that the server is running
checking = True
while checking:
status = subprocess.run(["ollama", "list"], capture_output=True, text=True)
if status.returncode == 0:
checking = False
else:
print(f"Ollama server not ready, checking again after {self.SERVE_CHECK_COOLDOWN} seconds...")
time.sleep(self.SERVE_CHECK_COOLDOWN)
print(f"Ollama server ready.")
return


@staticmethod
def add_args(parser: Any) -> None:
"""Add command line arguments for SWE-agent configuration."""
parser.add_argument("--swe-agent-model-name", type=str,
help="Name of the agent model to use (e.g. 'gpt-4o').")
help="Name of the agent model to use (e.g. 'gpt-4o', 'ollama/llama3.2:latest').")
parser.add_argument("--swe-agent-per-instance-cost-limit", type=float,
help="Per-instance cost limit for the agent model.")

help="Per-instance cost limit for the agent model; set to 0 for local models.")
parser.add_argument("--swe-agent-config", type=str,
help="Custom config file provided to SWE-Agent. Default config file is used if none is provided.")
parser.add_argument("--swe-agent-parser", type=str, choices=["thought_action", "function_call"],
help="Parsing strategy. Use 'thought_action' for local/Ollama models.")
parser.add_argument("--swe-agent-max-input-token", type=int,
help="Override max input tokens to avoid local-model warnings.")

@staticmethod
def parse_args(args: Any) -> Dict[str, Any]:
"""Parse command line arguments for SWE-agent configuration."""
return {
"swe_agent_model_name": args.swe_agent_model_name,
"swe_agent_per_instance_cost_limit": args.swe_agent_per_instance_cost_limit
"swe_agent_per_instance_cost_limit": args.swe_agent_per_instance_cost_limit,
"swe_agent_config": args.swe_agent_config,
"swe_agent_parser": args.swe_agent_parser,
"swe_agent_max_input_token": args.swe_agent_max_input_token,
}


def translate(self) -> None:
"""Execute the complete translation process using SWE-agent.

Expand Down Expand Up @@ -175,7 +235,6 @@ def _initialize_git_repo(self) -> None:
subprocess.run(self.GIT_ADD_ALL, cwd=self._temp_repo_path, check=True)
subprocess.run(self.GIT_COMMIT_INITIAL, cwd=self._temp_repo_path, check=True)


def run_swe_agent(self) -> bool:
"""Run the SWE-agent command and apply the resulting patch."""
command = self._build_swe_agent_command()
Expand All @@ -197,15 +256,23 @@ def run_swe_agent(self) -> bool:

def _build_swe_agent_command(self) -> List[str]:
"""Build the SWE-agent command with all required parameters."""
return [
cmd = [
"sweagent", "run",
f"--agent.model.name={self._swe_agent_model_name}",
f"--agent.model.per_instance_cost_limit={self._swe_agent_per_instance_cost_limit}",
f"--env.repo.path={self._temp_repo_path}",
"--env.deployment.image=python",
f"--problem_statement.path={self._translation_task_path}",
]

if self._swe_agent_parser:
cmd.append(f"--agent.tools.parse_function.type={self._swe_agent_parser}")
if self._swe_agent_max_input_token:
cmd.append(f"--agent.model.max_input_tokens={self._swe_agent_max_input_token}")
if self._swe_agent_config:
cmd.extend(["--config", self._swe_agent_config])

return cmd

def _apply_swe_agent_patch(self) -> bool:
"""Find and apply the patch file generated by SWE-agent."""
print("Applying patch...")
Expand Down
7 changes: 0 additions & 7 deletions targets/microXOR/cuda/repo/translation_task.md

This file was deleted.