Add autonomous orchestrator, agent modules, PR workflow, and in-memory learning memory#272
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an autonomous agent framework designed to analyze repositories, perform refactorings, apply security patches, and remediate CI failures. The implementation includes an orchestrator that coordinates these tasks and a memory module for learning from previous errors. Feedback focuses on improving the robustness of the Git automation by checking return codes, replacing hardcoded placeholders in the learning logic with actual fixes, and addressing the fragility of the search mechanism in the memory store, which currently uses hash prefix matching instead of semantic vector search.
| await _run("git", "checkout", "-b", "ai/auto-fix") | ||
| await _run("git", "add", ".") | ||
| await _run("git", "commit", "-m", "auto: AI patch") | ||
| await _run("git", "push", "origin", "ai/auto-fix") |
There was a problem hiding this comment.
The create_patch function executes a sequence of Git commands without checking their return codes. If a command fails (e.g., the branch already exists, or there are no changes to commit), the script continues blindly. This can lead to pushing incorrect state or attempting to push when no commit was made.
| await _run("git", "checkout", "-b", "ai/auto-fix") | |
| await _run("git", "add", ".") | |
| await _run("git", "commit", "-m", "auto: AI patch") | |
| await _run("git", "push", "origin", "ai/auto-fix") | |
| if await _run("git", "checkout", "-b", "ai/auto-fix") != 0: | |
| await _run("git", "checkout", "ai/auto-fix") | |
| await _run("git", "add", ".") | |
| if await _run("git", "commit", "-m", "auto: AI patch") == 0: | |
| await _run("git", "push", "origin", "ai/auto-fix") |
| print("Applying learned fix:", fix) | ||
| else: | ||
| print("No fix found, learning...") | ||
| learn_from_ci(output, "manual_fix_placeholder") |
There was a problem hiding this comment.
Hardcoding "manual_fix_placeholder" as the fix to learn prevents the autonomous system from acquiring actionable knowledge. This placeholder will be stored in memory and suggested for future occurrences of the same error, which will likely result in a no-op or repeated failure rather than a real fix.
|
|
||
| def search(self, query: str) -> list[dict[str, Any]]: | ||
| q = self._embed(query) | ||
| return [value for key, value in self.db.items() if key[:6] == q[:6]] |
There was a problem hiding this comment.
The search implementation uses a 6-character prefix match on a SHA256 hash. This is not a semantic or vector search and is extremely fragile for CI logs, which often contain dynamic content like timestamps, PIDs, or temporary file paths. Any minor variation in the error output will result in a completely different hash, causing the search to fail even for identical underlying issues.
Motivation
Description
.github/workflows/ai-bot.ymlto run the orchestrator, create a PR fromai/auto-fix, and enable auto-merge.agentspackage withorchestrator.py,analyzer.py,refactor.py,security.py,guard.py,ci.py, andpr.pyimplementing the autonomous flow (analyze -> refactor -> secure -> fix_ci -> create_patch).asyncio.create_subprocess_execinagents/ci.pyand async subprocess helpers inagents/pr.pyto avoid unsafe shell execution.memorypackage withvector_store.py(SHA-based embedding stub) andlearning.pyto store CI error/fix pairs and suggest previously learned fixes.Testing
python -m compileall agents memory .github/workflows/ai-bot.ymland all files compiled successfully.python -c "import agents.orchestrator, agents.ci, memory.learning; print('ok')"which printedok.Codex Task