An end-to-end LLM-powered repository-level code repair pipeline open-sourced by JD, featuring intelligent patch generation and collaborative test verification on SWE-bench benchmark, achieving 74.6% resolve rate on SWE-bench Verified with 30-50% lower resource consumption.
JoyCode Agent#
Overview#
JoyCode Agent (JoyCode SWE-bench Agent Pipeline) is an automated code repair system open-sourced by JD OpenSource. It automates the software defect repair workflow—from understanding Issue descriptions, locating code problems, generating repair patches, to creating verification test cases and executing closed-loop verification—forming a complete "Problem → Fix → Verify" automation chain.
Core Capabilities#
High Performance & Cost Efficiency#
- Achieves 74.6% resolve rate on SWE-bench Verified dataset (373/500)
- 30-50% lower resource consumption compared to top competitors
Patch-Test Collaborative Generation#
- Intelligent Test Generation: Automatically creates Fail2Pass and Pass2Pass tests with pre-validation
- Collaborative Verification: Patch and test co-generation for comprehensive validation
- Closed-loop Iteration: "Generate → Validate → Refine" cycle replaces single-generation mode
Intelligent Failure Attribution#
- Root cause analysis: Precisely distinguish Patch issues vs. test issues
- Targeted retry: Experience-driven retry strategy based on failure analysis
- CSR-driven learning: Historical success pattern retrieval optimization
Multi-Agent Architecture#
- Specialized agents: Testing Agent, Patch Agent, CSR Agent, Decision Agent
- ReAct-based "Observe-Think-Act" cycle
- LLM-driven Patch voting selection mechanism
Engineering Features#
- Containerized execution: Isolated environment based on SWE-bench Docker images
- Repository-level understanding: Multi-file coordination and cross-module reasoning
- Complete logging: Full trajectory recording with optional compression
- Multi-LLM support: Flexible model configuration for different pipeline stages
Architecture#
Pipeline Stages#
- Container Setup: Pull and start SWE-bench Docker image
- Test Generation (optional): Create and validate tests on original code
- Agent Execution: Use LLM Agent via
cli.pyto generate Patch - Verification: Run tests and evaluate Patch quality
- Post-processing (optional): Trajectory compression, similarity matching, intelligent retry
Repository Structure#
joycode/
├── run_patch_pipeline.py # Main entry
├── cli.py # Core Agent CLI
├── test_case_generator/ # Test generation logic
├── test/ # Test execution & verification
├── utils/docker_utils.py # Container management
├── llm_server/ # LLM integration layer
└── vote.py # Patch voting system
Installation & Quick Start#
Requirements#
- Python 3.11+
- Docker (access to
docker.1ms.runrequired) - LLM API keys (OpenAI, Anthropic, etc.)
Installation#
git clone https://github.com/jd-opensource/joycode-agent.git
cd joycode
conda create -n joycode python=3.11
conda activate joycode
pip install -r requirements.txt
Quick Start#
# Run with default config
python run_patch_pipeline.py --num-processes 1 --enable-post-processing
# Single instance
python run_patch_pipeline.py --problem-id django__django-11099 --num-processes 1
# Batch processing
python run_patch_pipeline.py --num-examples 10 --num-processes 4
Performance#
Results on SWE-bench Verified dataset:
| Repository | Resolve Rate |
|---|---|
| pytest-dev/pytest | 17/19 (89.47%) |
| scikit-learn/scikit-learn | 28/32 (87.5%) |
| pydata/xarray | 19/22 (86.36%) |
| django/django | 178/231 (77.06%) |
| sympy/sympy | 57/75 (76.0%) |
| sphinx-doc/sphinx | 29/44 (65.91%) |
| matplotlib/matplotlib | 25/34 (73.53%) |
| astropy/astropy | 13/22 (59.09%) |
| Total | 373/500 (74.6%) |
Use Cases#
- Automatic open-source project Issue repair
- Verification test case generation
- Repository-level code patch generation and verification
- Automated code repair pipeline construction
- Enterprise CI/CD integration for bug fixing
- AI programming research and SWE-bench baseline comparison