Improve coding agent reliability
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-08-21 23:46:16 +02:00
parent ed7b88ade4
commit 2df37b671b
11 changed files with 31 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
import os
import pwd
import shutil
import subprocess
from pathlib import Path
@@ -18,6 +19,13 @@ class AiderAgent:
task_file.chmod(0o600)
command = self.command(task_file)
coder = pwd.getpwnam("coder")
git_config = Path(coder.pw_dir) / ".gitconfig"
git_config.write_text(
"[user]\n\tname = LAI Automation Coder\n\temail = coder@localhost\n"
f"[safe]\n\tdirectory = {workspace.resolve()}\n"
)
git_config.chmod(0o600)
os.chown(git_config, coder.pw_uid, coder.pw_gid)
os.chown(task_file, coder.pw_uid, coder.pw_gid)
for path in workspace.rglob("*"):
if ".git" not in path.parts:
@@ -49,6 +57,9 @@ class AiderAgent:
timeout=900,
)
finally:
shutil.rmtree(workspace / ".aider.tags.cache.v4", ignore_errors=True)
for artifact in (".aider.chat.history.md", ".aider.input.history"):
(workspace / artifact).unlink(missing_ok=True)
os.chown(workspace, 0, coder.pw_gid, follow_symlinks=False)
workspace.chmod(0o775)
if result.returncode != 0:
@@ -72,4 +83,8 @@ class AiderAgent:
"--input-history-file",
"/dev/null",
"--no-analytics",
"--edit-format",
"diff",
"--timeout",
"60",
]