A minimal agentic coding assistant built in Java. It accepts a natural language prompt, calls an LLM via the OpenRouter API, and autonomously executes tool calls in a loop until the task is complete.
The agent runs a loop:
- Sends the user prompt (plus conversation history) to the LLM
- Receives a response — either a final answer or one or more tool calls
- Executes the requested tools and feeds results back into the conversation
- Repeats until the LLM returns a final answer (no more tool calls)
| Tool | Description |
|---|---|
Read |
Read a file from disk |
Write |
Write content to a file |
Bash |
Execute a shell command |
- Java 25
- Maven
- An OpenRouter API key
export OPENROUTER_API_KEY=your_key_hereOptionally override the base URL (defaults to https://openrouter.ai/api/v1):
export OPENROUTER_BASE_URL=https://openrouter.ai/api/v1./run.sh -p "your prompt here"Example:
./run.sh -p "List all Java files in this directory and count the lines in each one"Defaults to anthropic/claude-haiku-4.5 via OpenRouter. Change the model in Main.java in the invokeLLMApi method.
mvn package -Ddir=/tmp/llm-agent-build
java --enable-preview --enable-native-access=ALL-UNNAMED -jar /tmp/llm-agent-build/llm-agent.jar -p "your prompt"