execution-agent 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- execution_agent/__init__.py +8 -0
- execution_agent/__main__.py +5 -0
- execution_agent/agent.py +955 -0
- execution_agent/commands_interface.json +7 -0
- execution_agent/config.py +21 -0
- execution_agent/context.py +1565 -0
- execution_agent/docker_helpers_static.py +593 -0
- execution_agent/env.py +61 -0
- execution_agent/exceptions.py +17 -0
- execution_agent/exit_artifacts.py +350 -0
- execution_agent/main.py +1234 -0
- execution_agent/prompt_files/c_guidelines +481 -0
- execution_agent/prompt_files/command_stuck +7 -0
- execution_agent/prompt_files/cpp_guidelines +481 -0
- execution_agent/prompt_files/cycle_instruction +51 -0
- execution_agent/prompt_files/java_guidelines +37 -0
- execution_agent/prompt_files/javascript_guidelines +69 -0
- execution_agent/prompt_files/latest_containter_technology +7 -0
- execution_agent/prompt_files/python_guidelines +48 -0
- execution_agent/prompt_files/remove_progress_bars +1 -0
- execution_agent/prompt_files/rust_guidelines +53 -0
- execution_agent/prompt_files/search_workflows_summary +121 -0
- execution_agent/prompt_files/steps_list.json +32 -0
- execution_agent/prompt_files/summarize_cycle +13 -0
- execution_agent/prompt_files/tools_list +99 -0
- execution_agent/prompt_logging.py +311 -0
- execution_agent/repetition.py +39 -0
- execution_agent/shared_utils.py +507 -0
- execution_agent/state_persistence.py +286 -0
- execution_agent/tools.py +1611 -0
- execution_agent/trace_to_bash.py +281 -0
- execution_agent-0.1.0.dist-info/METADATA +231 -0
- execution_agent-0.1.0.dist-info/RECORD +37 -0
- execution_agent-0.1.0.dist-info/WHEEL +5 -0
- execution_agent-0.1.0.dist-info/entry_points.txt +2 -0
- execution_agent-0.1.0.dist-info/licenses/LICENSE.md +46 -0
- execution_agent-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Generate a bash script from agent execution trace.
|
|
4
|
+
|
|
5
|
+
This module takes the agent's command history and generates a standalone bash script
|
|
6
|
+
that reproduces the actions taken by the agent, including:
|
|
7
|
+
- Writing the Dockerfile
|
|
8
|
+
- Building the Docker image
|
|
9
|
+
- Starting the container
|
|
10
|
+
- Executing commands inside the container
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import shlex
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Any, List, Tuple
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _escape_bash_string(s: str) -> str:
|
|
22
|
+
"""
|
|
23
|
+
Escape a string for use in bash heredoc or double-quoted context.
|
|
24
|
+
Uses single quotes for maximum safety.
|
|
25
|
+
"""
|
|
26
|
+
# Replace single quotes with '\'' (end quote, escaped quote, start quote)
|
|
27
|
+
return s.replace("'", "'\\''")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _generate_file_write(filename: str, content: str, location: str) -> str:
|
|
31
|
+
"""
|
|
32
|
+
Generate bash command to write a file using heredoc.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
filename: The target file path
|
|
36
|
+
content: The file content
|
|
37
|
+
location: 'local' or 'container'
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Bash script fragment
|
|
41
|
+
"""
|
|
42
|
+
lines = []
|
|
43
|
+
lines.append(f"# Writing file: {filename} ({location})")
|
|
44
|
+
|
|
45
|
+
if location == "local":
|
|
46
|
+
# Local file write
|
|
47
|
+
lines.append(f"cat > '{_escape_bash_string(filename)}' <<'EOF_FILE'")
|
|
48
|
+
lines.append(content)
|
|
49
|
+
lines.append("EOF_FILE")
|
|
50
|
+
else:
|
|
51
|
+
# Container file write (exec into container)
|
|
52
|
+
lines.append(f"docker exec $CONTAINER_ID bash -c 'cat > {shlex.quote(filename)} <<'\"'\"'EOF_FILE'\"'\"''")
|
|
53
|
+
lines.append(content)
|
|
54
|
+
lines.append("EOF_FILE")
|
|
55
|
+
lines.append("'")
|
|
56
|
+
|
|
57
|
+
lines.append("")
|
|
58
|
+
return "\n".join(lines)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _generate_docker_build(dockerfile_dir: str, tag: str) -> str:
|
|
62
|
+
"""Generate bash command to build Docker image."""
|
|
63
|
+
lines = []
|
|
64
|
+
lines.append(f"# Building Docker image: {tag}")
|
|
65
|
+
lines.append(f"echo 'Building Docker image: {tag}'")
|
|
66
|
+
lines.append(f"docker build -t '{_escape_bash_string(tag)}' '{_escape_bash_string(dockerfile_dir)}'")
|
|
67
|
+
lines.append("BUILD_STATUS=$?")
|
|
68
|
+
lines.append("if [ $BUILD_STATUS -ne 0 ]; then")
|
|
69
|
+
lines.append(" echo 'ERROR: Docker build failed with exit code $BUILD_STATUS'")
|
|
70
|
+
lines.append(" exit $BUILD_STATUS")
|
|
71
|
+
lines.append("fi")
|
|
72
|
+
lines.append(f"DOCKER_TAG='{_escape_bash_string(tag)}'")
|
|
73
|
+
lines.append("")
|
|
74
|
+
return "\n".join(lines)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _generate_docker_start(tag: str) -> str:
|
|
78
|
+
"""Generate bash command to start Docker container."""
|
|
79
|
+
lines = []
|
|
80
|
+
lines.append(f"# Starting Docker container from image: {tag}")
|
|
81
|
+
lines.append(f"echo 'Starting Docker container from image: {tag}'")
|
|
82
|
+
lines.append(f"CONTAINER_ID=$(docker run -d -t '{_escape_bash_string(tag)}' tail -f /dev/null)")
|
|
83
|
+
lines.append("START_STATUS=$?")
|
|
84
|
+
lines.append("if [ $START_STATUS -ne 0 ]; then")
|
|
85
|
+
lines.append(" echo 'ERROR: Failed to start container'")
|
|
86
|
+
lines.append(" exit $START_STATUS")
|
|
87
|
+
lines.append("fi")
|
|
88
|
+
lines.append("echo 'Container started with ID: $CONTAINER_ID'")
|
|
89
|
+
lines.append("")
|
|
90
|
+
return "\n".join(lines)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _generate_terminal_command(command: str, in_container: bool) -> str:
|
|
94
|
+
"""
|
|
95
|
+
Generate bash command for terminal execution.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
command: The command to execute
|
|
99
|
+
in_container: Whether to execute inside container
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Bash script fragment
|
|
103
|
+
"""
|
|
104
|
+
lines = []
|
|
105
|
+
|
|
106
|
+
if in_container:
|
|
107
|
+
lines.append(f"# Executing in container: {command}")
|
|
108
|
+
lines.append(f"echo 'Executing: {_escape_bash_string(command)}'")
|
|
109
|
+
# Use bash -lc to ensure login shell environment
|
|
110
|
+
lines.append(f"docker exec $CONTAINER_ID bash -lc {shlex.quote(command)}")
|
|
111
|
+
lines.append("CMD_STATUS=$?")
|
|
112
|
+
lines.append("if [ $CMD_STATUS -ne 0 ]; then")
|
|
113
|
+
lines.append(f" echo 'WARNING: Command failed with exit code $CMD_STATUS'")
|
|
114
|
+
lines.append(" # Continuing despite error (agent may have handled this)")
|
|
115
|
+
lines.append("fi")
|
|
116
|
+
else:
|
|
117
|
+
lines.append(f"# Executing locally: {command}")
|
|
118
|
+
lines.append(f"echo 'Executing: {_escape_bash_string(command)}'")
|
|
119
|
+
lines.append(command)
|
|
120
|
+
lines.append("CMD_STATUS=$?")
|
|
121
|
+
lines.append("if [ $CMD_STATUS -ne 0 ]; then")
|
|
122
|
+
lines.append(f" echo 'WARNING: Command failed with exit code $CMD_STATUS'")
|
|
123
|
+
lines.append("fi")
|
|
124
|
+
|
|
125
|
+
lines.append("")
|
|
126
|
+
return "\n".join(lines)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def generate_bash_script_from_trace(
|
|
130
|
+
commands_and_summary: List[Tuple[str, Any]],
|
|
131
|
+
written_files: List[Tuple[str, str, str, str]],
|
|
132
|
+
dockerfile_tag: str = "",
|
|
133
|
+
project_path: str = "",
|
|
134
|
+
) -> str:
|
|
135
|
+
"""
|
|
136
|
+
Generate a standalone bash script from agent execution trace.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
commands_and_summary: List of (command_string, result_dict) tuples
|
|
140
|
+
written_files: List of (target_name, location, actual_path, content) tuples
|
|
141
|
+
dockerfile_tag: The Docker image tag if a container was built
|
|
142
|
+
project_path: The project path for context
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
Complete bash script as string
|
|
146
|
+
"""
|
|
147
|
+
lines = []
|
|
148
|
+
|
|
149
|
+
# Header
|
|
150
|
+
lines.append("#!/usr/bin/env bash")
|
|
151
|
+
lines.append("#")
|
|
152
|
+
lines.append("# Auto-generated bash script from execution agent trace")
|
|
153
|
+
lines.append(f"# Project: {project_path}")
|
|
154
|
+
lines.append("#")
|
|
155
|
+
lines.append("# This script reproduces the actions taken by the execution agent")
|
|
156
|
+
lines.append("#")
|
|
157
|
+
lines.append("")
|
|
158
|
+
lines.append("set -e # Exit on error")
|
|
159
|
+
lines.append("set -u # Exit on undefined variable")
|
|
160
|
+
lines.append("")
|
|
161
|
+
lines.append("# Configuration")
|
|
162
|
+
if dockerfile_tag:
|
|
163
|
+
lines.append(f"DOCKER_TAG='{_escape_bash_string(dockerfile_tag)}'")
|
|
164
|
+
lines.append("CONTAINER_ID=''")
|
|
165
|
+
lines.append("")
|
|
166
|
+
lines.append("# Cleanup function")
|
|
167
|
+
lines.append("cleanup() {")
|
|
168
|
+
lines.append(" if [ -n \"$CONTAINER_ID\" ]; then")
|
|
169
|
+
lines.append(" echo 'Cleaning up container: $CONTAINER_ID'")
|
|
170
|
+
lines.append(" docker stop $CONTAINER_ID >/dev/null 2>&1 || true")
|
|
171
|
+
lines.append(" docker rm $CONTAINER_ID >/dev/null 2>&1 || true")
|
|
172
|
+
lines.append(" fi")
|
|
173
|
+
lines.append("}")
|
|
174
|
+
lines.append("")
|
|
175
|
+
lines.append("# Register cleanup on exit")
|
|
176
|
+
lines.append("trap cleanup EXIT")
|
|
177
|
+
lines.append("")
|
|
178
|
+
lines.append("echo '========================================='")
|
|
179
|
+
lines.append("echo 'Starting execution agent trace replay'")
|
|
180
|
+
lines.append("echo '========================================='")
|
|
181
|
+
lines.append("")
|
|
182
|
+
|
|
183
|
+
# Track state
|
|
184
|
+
container_started = False
|
|
185
|
+
dockerfile_dir = None
|
|
186
|
+
|
|
187
|
+
# Process written files first (to create Dockerfile)
|
|
188
|
+
if written_files:
|
|
189
|
+
lines.append("# ============================================")
|
|
190
|
+
lines.append("# File writes")
|
|
191
|
+
lines.append("# ============================================")
|
|
192
|
+
lines.append("")
|
|
193
|
+
|
|
194
|
+
for target_name, location, actual_path, content in written_files:
|
|
195
|
+
# Check if this is a Dockerfile
|
|
196
|
+
is_dockerfile = target_name.lower() == "dockerfile" or target_name.lower().endswith(".dockerfile")
|
|
197
|
+
|
|
198
|
+
if is_dockerfile and location == "local":
|
|
199
|
+
# Extract directory for build
|
|
200
|
+
dockerfile_dir = str(Path(actual_path).parent)
|
|
201
|
+
lines.append(f"# Creating Dockerfile directory")
|
|
202
|
+
lines.append(f"mkdir -p '{_escape_bash_string(dockerfile_dir)}'")
|
|
203
|
+
lines.append("")
|
|
204
|
+
|
|
205
|
+
lines.append(_generate_file_write(actual_path, content, location))
|
|
206
|
+
|
|
207
|
+
# If Dockerfile was written, build and start container
|
|
208
|
+
if dockerfile_dir and dockerfile_tag:
|
|
209
|
+
lines.append("# ============================================")
|
|
210
|
+
lines.append("# Docker image build and container start")
|
|
211
|
+
lines.append("# ============================================")
|
|
212
|
+
lines.append("")
|
|
213
|
+
lines.append(_generate_docker_build(dockerfile_dir, dockerfile_tag))
|
|
214
|
+
lines.append(_generate_docker_start(dockerfile_tag))
|
|
215
|
+
container_started = True
|
|
216
|
+
|
|
217
|
+
# Process commands
|
|
218
|
+
if commands_and_summary:
|
|
219
|
+
lines.append("# ============================================")
|
|
220
|
+
lines.append("# Command execution")
|
|
221
|
+
lines.append("# ============================================")
|
|
222
|
+
lines.append("")
|
|
223
|
+
|
|
224
|
+
for cmd_str, result in commands_and_summary:
|
|
225
|
+
# Parse command from "Call to tool TOOL_NAME with arguments ARGS" format
|
|
226
|
+
if cmd_str.startswith("Call to tool linux_terminal with arguments "):
|
|
227
|
+
args_json = cmd_str[len("Call to tool linux_terminal with arguments "):]
|
|
228
|
+
try:
|
|
229
|
+
args = json.loads(args_json)
|
|
230
|
+
command = args.get("command", "")
|
|
231
|
+
if command:
|
|
232
|
+
lines.append(_generate_terminal_command(command, container_started))
|
|
233
|
+
except json.JSONDecodeError:
|
|
234
|
+
# Skip malformed commands
|
|
235
|
+
pass
|
|
236
|
+
|
|
237
|
+
# Footer
|
|
238
|
+
lines.append("# ============================================")
|
|
239
|
+
lines.append("# Execution complete")
|
|
240
|
+
lines.append("# ============================================")
|
|
241
|
+
lines.append("")
|
|
242
|
+
lines.append("echo '========================================='")
|
|
243
|
+
lines.append("echo 'Execution agent trace replay complete'")
|
|
244
|
+
lines.append("echo '========================================='")
|
|
245
|
+
lines.append("")
|
|
246
|
+
lines.append("# Note: Container is still running. Use 'docker exec $CONTAINER_ID bash' to access it.")
|
|
247
|
+
lines.append("# To stop and remove the container, press Ctrl+C or let the script exit naturally.")
|
|
248
|
+
|
|
249
|
+
return "\n".join(lines)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def save_bash_script_from_agent(
|
|
253
|
+
agent: Any,
|
|
254
|
+
output_path: str | Path,
|
|
255
|
+
) -> None:
|
|
256
|
+
"""
|
|
257
|
+
Generate and save bash script from agent state.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
agent: ExecutionAgent instance with commands_and_summary and written_files
|
|
261
|
+
output_path: Path where to save the generated script
|
|
262
|
+
"""
|
|
263
|
+
commands_and_summary = getattr(agent, "commands_and_summary", [])
|
|
264
|
+
written_files = getattr(agent, "written_files", [])
|
|
265
|
+
dockerfile_tag = getattr(agent, "docker_tag", "")
|
|
266
|
+
project_path = getattr(agent, "project_path", "")
|
|
267
|
+
|
|
268
|
+
script = generate_bash_script_from_trace(
|
|
269
|
+
commands_and_summary=commands_and_summary,
|
|
270
|
+
written_files=written_files,
|
|
271
|
+
dockerfile_tag=dockerfile_tag,
|
|
272
|
+
project_path=project_path,
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
output_path = Path(output_path)
|
|
276
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
277
|
+
output_path.write_text(script, encoding="utf-8")
|
|
278
|
+
|
|
279
|
+
# Make script executable
|
|
280
|
+
import stat
|
|
281
|
+
output_path.chmod(output_path.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: execution-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automated project building and test execution inside Docker containers
|
|
5
|
+
Author: Islem Bouzenia
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Islem BOUZENIA - SOFTWARELAB
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
THIS SOFTWARE IS BASED ON THE MINI-SWE-AGENT PROJECT,
|
|
29
|
+
ORIGINAL LICENSE OF MINI-SWE-AGENT BELOW:
|
|
30
|
+
|
|
31
|
+
MIT License
|
|
32
|
+
|
|
33
|
+
Copyright (c) 2025 Kilian A. Lieret and Carlos E. Jimenez
|
|
34
|
+
|
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
36
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
37
|
+
in the Software without restriction, including without limitation the rights
|
|
38
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
39
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
40
|
+
furnished to do so, subject to the following conditions:
|
|
41
|
+
|
|
42
|
+
The above copyright notice and this permission notice shall be included in all
|
|
43
|
+
copies or substantial portions of the Software.
|
|
44
|
+
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
46
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
47
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
48
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
49
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
50
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
51
|
+
SOFTWARE.
|
|
52
|
+
Project-URL: Repository, https://github.com/sola-st/ExecutionAgent
|
|
53
|
+
Keywords: testing,docker,automation,agents,ci
|
|
54
|
+
Classifier: Development Status :: 4 - Beta
|
|
55
|
+
Classifier: Operating System :: OS Independent
|
|
56
|
+
Classifier: Intended Audience :: Developers
|
|
57
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
58
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
59
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
60
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
61
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
62
|
+
Classifier: Topic :: Software Development :: Testing
|
|
63
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
64
|
+
Requires-Python: >=3.10
|
|
65
|
+
Description-Content-Type: text/markdown
|
|
66
|
+
License-File: LICENSE.md
|
|
67
|
+
Requires-Dist: mini-swe-agent
|
|
68
|
+
Requires-Dist: docker
|
|
69
|
+
Requires-Dist: pydantic>=2.0
|
|
70
|
+
Requires-Dist: pyyaml
|
|
71
|
+
Requires-Dist: requests
|
|
72
|
+
Provides-Extra: dev
|
|
73
|
+
Requires-Dist: pytest; extra == "dev"
|
|
74
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
75
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
76
|
+
Requires-Dist: ruff; extra == "dev"
|
|
77
|
+
Dynamic: license-file
|
|
78
|
+
|
|
79
|
+
# Execution Agent
|
|
80
|
+
|
|
81
|
+
[](https://pypi.org/project/execution-agent/)
|
|
82
|
+
[](https://www.python.org/downloads/)
|
|
83
|
+
[](https://opensource.org/licenses/MIT)
|
|
84
|
+
|
|
85
|
+
An LLM-powered agent that automatically sets up, builds, and runs test suites for software projects inside Docker containers. Given a Git repository, it analyzes the project, creates a Dockerfile, installs dependencies, and executes the test suite — all autonomously.
|
|
86
|
+
|
|
87
|
+
## Installation
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pip install execution-agent
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Requires Python 3.10+ and Docker installed on the host.
|
|
94
|
+
|
|
95
|
+
## Quick Start
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# 1. Set your API key
|
|
99
|
+
export OPENAI_API_KEY="your-api-key"
|
|
100
|
+
|
|
101
|
+
# 2. Create a project metadata file
|
|
102
|
+
cat > project_meta_data.json << 'EOF'
|
|
103
|
+
{
|
|
104
|
+
"project_path": "my_project",
|
|
105
|
+
"project_url": "https://github.com/username/my_project",
|
|
106
|
+
"language": "Python",
|
|
107
|
+
"budget": 40
|
|
108
|
+
}
|
|
109
|
+
EOF
|
|
110
|
+
|
|
111
|
+
# 3. Run the agent
|
|
112
|
+
execution-agent --experiment-file project_meta_data.json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## How It Works
|
|
116
|
+
|
|
117
|
+
1. **Context gathering** — Clones the repository, inspects CI configs, README, and dependency files
|
|
118
|
+
2. **Dockerfile generation** — Creates a Docker environment tailored to the project
|
|
119
|
+
3. **Build & test** — Iteratively runs commands inside the container to install, build, and test
|
|
120
|
+
4. **Retry with learning** — If the budget is exhausted, retries with lessons from previous attempts
|
|
121
|
+
5. **Forced exit** — As a last resort, a knowledge model synthesizes a final solution from all context
|
|
122
|
+
|
|
123
|
+
The task is considered successful when ~80%+ of tests pass.
|
|
124
|
+
|
|
125
|
+
## Command-Line Options
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
execution-agent --experiment-file META.json [OPTIONS]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Option | Description | Default |
|
|
132
|
+
|--------|-------------|---------|
|
|
133
|
+
| `--experiment-file` | Path to project metadata JSON **(required)** | — |
|
|
134
|
+
| `--task` | Custom task string | Auto-generated |
|
|
135
|
+
| `--task-file` | File containing custom task instructions | — |
|
|
136
|
+
| `--model` | LLM model for the agent | `gpt-5-nano` |
|
|
137
|
+
| `--knowledge-model` | LLM model for context analysis | `gpt-5-mini` |
|
|
138
|
+
| `--api-key` | OpenAI API key | `$OPENAI_API_KEY` |
|
|
139
|
+
| `--workspace-root` | Output directory | `execution_agent_workspace` |
|
|
140
|
+
| `--prompt-files` | Custom prompt templates directory | Bundled defaults |
|
|
141
|
+
| `--log-level` | `DEBUG` / `INFO` / `WARNING` / `ERROR` | `INFO` |
|
|
142
|
+
| `--run-log-dir` | Custom directory for run logs | Auto-generated |
|
|
143
|
+
| `--max-retries` | Retries after budget exhaustion | `2` |
|
|
144
|
+
|
|
145
|
+
You can also run it as a module:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
python -m execution_agent --experiment-file project_meta_data.json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Project Metadata Format
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"project_path": "scipy",
|
|
156
|
+
"project_name": "SciPy",
|
|
157
|
+
"project_url": "https://github.com/scipy/scipy",
|
|
158
|
+
"language": "Python",
|
|
159
|
+
"budget": 40
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
| Field | Description |
|
|
164
|
+
|-------|-------------|
|
|
165
|
+
| `project_path` | Directory name for the project |
|
|
166
|
+
| `project_name` | Human-readable name (optional) |
|
|
167
|
+
| `project_url` | Git repository URL |
|
|
168
|
+
| `language` | Primary language: `Python`, `Java`, `Javascript`, `C`, `C++`, `Rust` |
|
|
169
|
+
| `budget` | Maximum execution cycles (steps) |
|
|
170
|
+
|
|
171
|
+
## Agent Tools
|
|
172
|
+
|
|
173
|
+
The agent can use these tools during execution:
|
|
174
|
+
|
|
175
|
+
| Tool | Description |
|
|
176
|
+
|------|-------------|
|
|
177
|
+
| `linux_terminal` | Execute bash commands inside the Docker container |
|
|
178
|
+
| `read_file` | Read file contents |
|
|
179
|
+
| `write_to_file` | Write files (Dockerfiles, scripts, etc.) |
|
|
180
|
+
| `search_docker_image` | Search Docker Hub for base images |
|
|
181
|
+
| `goals_accomplished` | Signal successful task completion |
|
|
182
|
+
|
|
183
|
+
## Output Structure
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
execution_agent_workspace/
|
|
187
|
+
├── _run_logs/<project>/<timestamp>/
|
|
188
|
+
│ ├── run.log # Human-readable log
|
|
189
|
+
│ ├── run.jsonl # Structured JSON log
|
|
190
|
+
│ ├── messages.json # Full LLM conversation history
|
|
191
|
+
│ ├── replay_trace.sh # Bash script to replay all commands
|
|
192
|
+
│ ├── tool_metrics.json # Tool execution statistics
|
|
193
|
+
│ ├── cycles_chats/ # Per-cycle LLM prompts
|
|
194
|
+
│ ├── success_artifacts/ # On success: Dockerfile, commands.sh, launch.sh
|
|
195
|
+
│ └── forced_exit_cycle/ # On budget exhaustion: final attempt artifacts
|
|
196
|
+
└── <project>/ # Cloned repository
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Reproducing a Successful Run
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
cd execution_agent_workspace/_run_logs/<project>/<timestamp>/success_artifacts/
|
|
203
|
+
./launch.sh
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Retry Mechanism
|
|
207
|
+
|
|
208
|
+
1. **Attempt 1**: Initial run with full budget
|
|
209
|
+
2. **Attempts 2–N**: Retries informed by lessons from previous attempts
|
|
210
|
+
3. **Forced exit cycle**: If all retries fail, a knowledge model generates a final Dockerfile and test script based on everything learned
|
|
211
|
+
|
|
212
|
+
Each attempt produces a summary with problems encountered, progress made, and suggestions for the next attempt.
|
|
213
|
+
|
|
214
|
+
## Language Support
|
|
215
|
+
|
|
216
|
+
Built-in guidelines are included for:
|
|
217
|
+
Python, Java, JavaScript/TypeScript, C, C++, and Rust.
|
|
218
|
+
|
|
219
|
+
## Environment Variables
|
|
220
|
+
|
|
221
|
+
| Variable | Description |
|
|
222
|
+
|----------|-------------|
|
|
223
|
+
| `OPENAI_API_KEY` | API key for LLM access (required) |
|
|
224
|
+
| `OPENAI_MODEL` | Default model (fallback for `--model`) |
|
|
225
|
+
| `KNOWLEDGE_MODEL` | Default knowledge model (fallback for `--knowledge-model`) |
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT — see [LICENSE.md](LICENSE.md) for details.
|
|
230
|
+
|
|
231
|
+
Based on [mini-swe-agent](https://github.com/SWE-agent/mini-SWE-agent) by Kilian Lieret and Carlos E. Jimenez.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
execution_agent/__init__.py,sha256=fR3JkcelbgtlDNjPr3ise_HWlg08EoFQ4s6m-i28NOE,218
|
|
2
|
+
execution_agent/__main__.py,sha256=zSkNxro3i8T6OJmFpt3WF0i_eCcaWULyzFG0yUyUdz4,117
|
|
3
|
+
execution_agent/agent.py,sha256=QbE0KPIUQUhZUa5g7TfdbCXY4vDu6P6f4xwyNtkEPDk,43501
|
|
4
|
+
execution_agent/commands_interface.json,sha256=n4oSWLjNMLBo8EUs6SblfmWirig6lOqXsKt68PNc5Q4,185
|
|
5
|
+
execution_agent/config.py,sha256=puljGyamXSLq5ZpLPWUVvqKjWt1DTpb0KJeJeY_cUo4,565
|
|
6
|
+
execution_agent/context.py,sha256=CTyZGAKqufsd21cYX3IYXodxhpVkGKYzGxm5EIFIffM,63244
|
|
7
|
+
execution_agent/docker_helpers_static.py,sha256=jfJV7RCrc4FudUgspVy1tSUJ7uBYUvfpLMur4WuG6V4,21222
|
|
8
|
+
execution_agent/env.py,sha256=Jv6GsUV0Rt4N0Sz6J8_TtKQVkC0KXJjAFYUo-8xqUsg,2086
|
|
9
|
+
execution_agent/exceptions.py,sha256=-zCwN1Cit3-N81A11DL3bd75PyaFhone1py8K5Q9Sd4,445
|
|
10
|
+
execution_agent/exit_artifacts.py,sha256=s-kLRq-wKrINd6oVGd41riv2cQ1WaNKNaOA7J6JghSo,13444
|
|
11
|
+
execution_agent/main.py,sha256=PA2t6e-MLTVO5hJhbaZCocySSqfJ5zxZ-iZswEo45G8,47714
|
|
12
|
+
execution_agent/prompt_logging.py,sha256=CXsUhC52BlES7e_9w32XZkuomNMfd3O7l10bJ3s1bA8,10146
|
|
13
|
+
execution_agent/repetition.py,sha256=Pk0e78S4TfSNZHU1dEx0pT_Yh6kuOUsob58FAIuwAzA,1119
|
|
14
|
+
execution_agent/shared_utils.py,sha256=uEXb-W8gCsczeMHIS92cLy-CB-s79zZYKvrFevLFJPQ,16216
|
|
15
|
+
execution_agent/state_persistence.py,sha256=BJeDeV4DfF-ba_NR8RXw18WtRkmr1xuJ1JQbdlYGBsU,9786
|
|
16
|
+
execution_agent/tools.py,sha256=l6aK1wKRHL-a3U4AUVqulmDLmNvZwYqJ2w4ZJRx8bhI,63022
|
|
17
|
+
execution_agent/trace_to_bash.py,sha256=r-syqd3tEmJBtuagnanQVuHy2UpeEM51awqUXSx-tVU,10612
|
|
18
|
+
execution_agent/prompt_files/c_guidelines,sha256=H7XoOLDPjllJBSV69Gly6g2MANbXD3fAdIbewpE1FEg,9679
|
|
19
|
+
execution_agent/prompt_files/command_stuck,sha256=N7GZWs03OmA_f6V2nkCC3m8W_2iliiv22mdb8Pr3oCg,610
|
|
20
|
+
execution_agent/prompt_files/cpp_guidelines,sha256=f1wFumFbM3iPqSFCHOuOmOKsP_BbL-_1STimGIT3Mk0,9678
|
|
21
|
+
execution_agent/prompt_files/cycle_instruction,sha256=2KSeSxVy8K2Vgbi-r0H-JIT5ym7sOH83nwdywNplYQw,7575
|
|
22
|
+
execution_agent/prompt_files/java_guidelines,sha256=VMcfzLAk6twgSKuwmtBK9ypMJgsGnZeXhu21I3xLfa8,1866
|
|
23
|
+
execution_agent/prompt_files/javascript_guidelines,sha256=IsVWWyQLdfTJXSb-1IKP7WIrzrC5ObaqnnfJReB6AEI,2427
|
|
24
|
+
execution_agent/prompt_files/latest_containter_technology,sha256=Dcc7harK-ArIst881KxUtjdhb6H32nYKdFZ5sKotkJA,1051
|
|
25
|
+
execution_agent/prompt_files/python_guidelines,sha256=iFtKigcRxVFXv5viKrUqESM7fcbfGxOH_pikwyBxfW4,2405
|
|
26
|
+
execution_agent/prompt_files/remove_progress_bars,sha256=mAVenH9uMrLEqjO-KVG1MFdJRrmIqheUcZi_OykklNo,1001
|
|
27
|
+
execution_agent/prompt_files/rust_guidelines,sha256=e4vVGBJ7pDge4UPLEkeADX9ItTG8Pg6fRZF9YCE6Fr4,1855
|
|
28
|
+
execution_agent/prompt_files/search_workflows_summary,sha256=iptvpxk3fdIS9o0o320kzgtzTpoZONskwtm4oYy5OD8,5014
|
|
29
|
+
execution_agent/prompt_files/steps_list.json,sha256=guBRg6Xq-5VlKAoJsrxPh6mImElrLqNUL8nAOlu3JiY,3316
|
|
30
|
+
execution_agent/prompt_files/summarize_cycle,sha256=ZjI-9xJcxQtAlLGz65tIDyp4idHKBekU_w9TrWuQ368,1450
|
|
31
|
+
execution_agent/prompt_files/tools_list,sha256=w6ArSL_UfZfFK9wr7EHiD7BPRRUImQ52OXAeK8cdh8Y,5734
|
|
32
|
+
execution_agent-0.1.0.dist-info/licenses/LICENSE.md,sha256=AbmfZDHcvMU164cjzGqXrbWAueRAIbQ_4RKnQzkb0uY,2278
|
|
33
|
+
execution_agent-0.1.0.dist-info/METADATA,sha256=w9FxCbHR9cEjd0_8sxKGTbPDos9tu6SsXqMLPVddSLE,9309
|
|
34
|
+
execution_agent-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
35
|
+
execution_agent-0.1.0.dist-info/entry_points.txt,sha256=K1p3Da64m3-JQlkusABjswju5IFgAitjdEv1g_d2vrw,62
|
|
36
|
+
execution_agent-0.1.0.dist-info/top_level.txt,sha256=csvtbtuj22p3F8-f-Gdn3pj6bGYAKJfLeFrjxlqrIag,16
|
|
37
|
+
execution_agent-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Islem BOUZENIA - SOFTWARELAB
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
THIS SOFTWARE IS BASED ON THE MINI-SWE-AGENT PROJECT,
|
|
24
|
+
ORIGINAL LICENSE OF MINI-SWE-AGENT BELOW:
|
|
25
|
+
|
|
26
|
+
MIT License
|
|
27
|
+
|
|
28
|
+
Copyright (c) 2025 Kilian A. Lieret and Carlos E. Jimenez
|
|
29
|
+
|
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
31
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
32
|
+
in the Software without restriction, including without limitation the rights
|
|
33
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
34
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
35
|
+
furnished to do so, subject to the following conditions:
|
|
36
|
+
|
|
37
|
+
The above copyright notice and this permission notice shall be included in all
|
|
38
|
+
copies or substantial portions of the Software.
|
|
39
|
+
|
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
41
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
42
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
43
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
44
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
45
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
46
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
execution_agent
|