Skip to content

Tiromachelan/ADK-java-coder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ADK Java Coder

An AI agent pipeline built with Google ADK that autonomously develops Java programs from a natural-language description. It generates an initial implementation, writes JUnit5 unit tests, compiles and runs them, and iteratively improves the code until all tests pass.

Architecture

SequentialAgent (java_coder)
├── LlmAgent: first_version       ← generates initial Java source
└── LoopAgent: tdd_loop (max 20)
    └── SequentialAgent: tdd_cycle
        ├── LlmAgent: test_writer     ← writes JUnit5 tests
        ├── LlmAgent: test_runner     ← compiles & runs tests
        └── LlmAgent: code_improver   ← fixes failures

The loop exits early when all tests pass, or after 20 iterations.

Setup

Requirements: Python 3.11+, Java JDK (for javac / java), internet access (to download JUnit5 jar on first run).

python -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install -r requirements.txt

cp .env.example .env
# Edit .env and set your OPENAI_API_KEY

Get an API key at https://platform.openai.com/api-keys

Usage

python main.py "Write a Calculator class with add, subtract, multiply, and divide methods"

Generated Java files are written to workspace/ (gitignored). The final source is printed to stdout at the end.

Project Layout

agents/               ← one file per LlmAgent
tools/shell_tools.py  ← FunctionTools: write_file, read_file, compile_java, run_tests, download_junit5
pipeline.py           ← assembles the full agent tree
main.py               ← CLI entry point
workspace/            ← runtime-generated Java files and compiled classes (gitignored)

About

ADK Agent pipeline for creating Java programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages