Summary
The implementer_node in backend/agents.py hardcodes the commit path to feature_issue_{issue_number}.py (line 607). This means the agent always creates a brand-new throwaway script in the target repository, regardless of what the Architect's directive or the issue description says. It never reads existing files, never applies a patch, and never makes a meaningful change to the actual codebase.
Affected Code
# backend/agents.py:607 (current — broken behaviour)
path = f"feature_issue_{issue_number}.py"
And the LLM prompt reinforces this broken pattern:
# backend/agents.py:559-560
system_prompt = "You are the Implementer Agent. Write a tiny python script that implements
the core logic of the idea. Keep it very short. Output ONLY the Python script."
user_prompt = f"Write code for: {idea}"
The agent is instructed to write a generic script, not to modify any specific file in the repository.
Steps to Reproduce
- Run AutoMaintainer against any target repository with a real open issue.
- Watch the Implementer commit its "code".
- Check the resulting PR in the target repository — it will contain a single new file called
feature_issue_N.py containing a short standalone Python script that has no relation to the actual codebase structure.
Impact
| Expectation |
Actual Behaviour |
| Agent reads the target file identified by the Architect |
❌ Agent never fetches any existing file |
| Agent patches the correct lines in the correct file |
❌ Agent creates a new unrelated feature_issue_N.py |
| Merged PR improves the target repository |
❌ Merged PR adds a useless throwaway script |
| Self-correcting loop fixes real bugs |
❌ Maintainer reviews a script with no context |
This is the single most critical functional bug in the system — it makes the entire agentic loop produce zero value.
Root Cause
The Architect directive contains precise file and line references (e.g. "Modify agents.py:54-76 to add retry logic"), but the Implementer node never parses this directive. It ignores the file path entirely and writes free-form code to a hardcoded new file.
Proposed Fix
The Implementer node needs to be rewritten to:
- Parse the Architect directive to extract the target file path and line range.
- Fetch the current file contents from GitHub using
gh_repo.get_contents(file_path).
- Prompt the LLM with the existing code as context, asking it to produce a targeted patch/replacement for the specified lines only.
- Commit only the modified file (not a new
feature_issue_N.py).
# backend/agents.py — proposed implementer_node logic sketch
# 1. Extract target file from directive
import re
match = re.search(r'([\w/.-]+\.\w+):(\d+)-(\d+)', directive)
if match:
target_file = match.group(1)
start_line, end_line = int(match.group(2)), int(match.group(3))
else:
target_file = None
# 2. Fetch current file from GitHub
if target_file:
try:
file_obj = gh_repo.get_contents(target_file, ref=default_branch)
original_content = file_obj.decoded_content.decode('utf-8')
except Exception:
original_content = ""
# 3. Ask LLM to patch specific lines
system_prompt = (
"You are the Implementer Agent. You will receive the full contents of a source file "
"and a directive specifying which lines to change and why. Output ONLY the complete "
"modified file contents — no explanations, no markdown fences."
)
user_prompt = (
f"Directive: {idea}\n\n"
f"File: {target_file}\n"
f"Lines to change: {start_line}–{end_line}\n\n"
f"Current file contents:\n{original_content}"
)
# 4. Commit the modified target file (not a new file)
path = target_file # ← use the actual file path
Files to Change
backend/agents.py:
- Lines 556–560: Update
implementer_node system/user prompts to include existing file context.
- Line 607: Replace hardcoded
path = f"feature_issue_{issue_number}.py" with dynamic path parsed from the Architect directive.
- Lines 618–623: Update
create_file to update_file when the target file already exists.
Acceptance Criteria
Summary
The
implementer_nodeinbackend/agents.pyhardcodes the commit path tofeature_issue_{issue_number}.py(line 607). This means the agent always creates a brand-new throwaway script in the target repository, regardless of what the Architect's directive or the issue description says. It never reads existing files, never applies a patch, and never makes a meaningful change to the actual codebase.Affected Code
And the LLM prompt reinforces this broken pattern:
The agent is instructed to write a generic script, not to modify any specific file in the repository.
Steps to Reproduce
feature_issue_N.pycontaining a short standalone Python script that has no relation to the actual codebase structure.Impact
feature_issue_N.pyThis is the single most critical functional bug in the system — it makes the entire agentic loop produce zero value.
Root Cause
The Architect directive contains precise file and line references (e.g.
"Modify agents.py:54-76 to add retry logic"), but the Implementer node never parses this directive. It ignores the file path entirely and writes free-form code to a hardcoded new file.Proposed Fix
The Implementer node needs to be rewritten to:
gh_repo.get_contents(file_path).feature_issue_N.py).Files to Change
backend/agents.py:implementer_nodesystem/user prompts to include existing file context.path = f"feature_issue_{issue_number}.py"with dynamic path parsed from the Architect directive.create_filetoupdate_filewhen the target file already exists.Acceptance Criteria
agents.py:54-76), the Implementer fetches and modifies that exact file.feature_issue_N.py.