Skip to content

eduardocoutodev/llm-agent-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llm-agent

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.

How it works

The agent runs a loop:

  1. Sends the user prompt (plus conversation history) to the LLM
  2. Receives a response — either a final answer or one or more tool calls
  3. Executes the requested tools and feeds results back into the conversation
  4. Repeats until the LLM returns a final answer (no more tool calls)

Tools

Tool Description
Read Read a file from disk
Write Write content to a file
Bash Execute a shell command

Requirements

Setup

export OPENROUTER_API_KEY=your_key_here

Optionally override the base URL (defaults to https://openrouter.ai/api/v1):

export OPENROUTER_BASE_URL=https://openrouter.ai/api/v1

Usage

./run.sh -p "your prompt here"

Example:

./run.sh -p "List all Java files in this directory and count the lines in each one"

Model

Defaults to anthropic/claude-haiku-4.5 via OpenRouter. Change the model in Main.java in the invokeLLMApi method.

Build

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"

About

Minimal agentic coding assistant in Java. Accepts a natural language prompt and autonomously executes Read, Write, and Bash tool calls in a loop via OpenRouter's LLM API until the task is complete.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors