Skip to content

random-droid/JavaLLMAgent

Repository files navigation

Enterprise LLM Agent Orchestration: Embabel GOAP vs LangGraph

A comprehensive comparison of two leading approaches to building production-ready LLM agents:

  • Embabel (Java GOAP): Deterministic planning with enterprise focus
  • LangGraph (Python): State-based flexible orchestration

Project Overview

This project demonstrates identical deterministic workflows implemented in two different frameworks for fair side-by-side comparison:

1. Java GOAP Agent (Spring AI)

  • Pattern: Goal-Oriented Action Planning (GOAP) with deterministic 3-step execution
  • Technology: Spring Boot, Spring AI, Java Records
  • Focus: Type safety, enterprise integration, high throughput
  • Location: java-tool-server/

2. Python LangGraph Agent (State-Based)

  • Pattern: State graph orchestration with deterministic 3-step execution
  • Technology: LangGraph, LangChain, Pydantic
  • Focus: Rapid development, flexibility, Python ecosystem
  • Location: langgraph-advisor/

Identical 3-Step Workflow

Both implementations follow the exact same workflow:

  1. Step 1: Call Technical Tool Server → Get quantitative data (SMA, RSI, MACD)
  2. Step 2: Call RAG Service → Retrieve qualitative market intelligence
  3. Step 3: LLM Synthesis → Generate investment thesis with recommendation

See SIDE_BY_SIDE_COMPARISON.md for detailed execution traces and comparison.

Real Market Data Integration

Both frameworks now integrate real Yahoo Finance data:

Java GOAP

  • Uses yahoofinance-api library (v3.17.0)
  • Fetches real historical data (90 days)
  • Calculates technical indicators (SMA, RSI, MACD)
  • Gracefully degrades to mock data if Yahoo Finance unavailable

Python LangGraph

  • Uses yfinance library (v0.2.66)
  • Fetches real market data via Yahoo Finance API
  • Calculates same technical indicators
  • Multi-layer fallback: Yahoo Finance → MCP Server → Mock data

Note: Yahoo Finance unofficial APIs may hit rate limits. Both implementations handle this gracefully with fallback mechanisms.

Testing Both Frameworks

Java GOAP Execution

curl -X POST http://localhost:8080/ai/agent/thesis \
  -H "Content-Type: application/json" \
  -d '{"ticker":"AAPL"}'

Expected Output:

=== Java GOAP Workflow (Deterministic 3-Step) ===
[Java GOAP - Step 1/3] Call Technical Tool Server
[Java GOAP - Step 1/3] ✓ Retrieved: BULLISH
[Java GOAP - Step 2/3] Call RAG Service
[Java GOAP - Step 2/3] ✓ Retrieved 699 characters
[Java GOAP - Step 3/3] LLM Synthesis
[Java GOAP - Step 3/3] ✓ Recommendation: BUY (Confidence: 75.0%)
=== Java GOAP Workflow Complete ===

Python LangGraph Execution

python langgraph-advisor/main_advisor.py AAPL

Expected Output:

=== Python LangGraph Workflow (Deterministic 3-Step) ===
[LangGraph - Step 1/3] Call Technical Tool Server
[LangGraph - Step 1/3] ✓ Retrieved: BULLISH
[LangGraph - Step 2/3] Call RAG Service
[LangGraph - Step 2/3] ✓ Retrieved 473 characters
[LangGraph - Step 3/3] LLM Synthesis
[LangGraph - Step 3/3] ✓ Recommendation: BUY (Confidence: 75.0%)
=== Python LangGraph Workflow Complete ===

Components

Java Tool Server (Port 8080)

Quantitative tool server providing financial calculations:

  • Technical Indicators: SMA, RSI, MACD calculations
  • GOAP Investment Agent: 3-step workflow for investment thesis
  • Mock RAG Service: Qualitative market intelligence
  • MCP Protocol: HTTP API for microservice communication

Python LangGraph Advisor

State-based orchestration mirroring Java GOAP workflow:

  • Node 1: Call Java MCP Tool Server
  • Node 2: RAG search for qualitative data
  • Node 3: LLM synthesis of investment thesis

GOAP Workflow

Both implementations follow the same 3-step Goal-Oriented Action Planning:

  1. Call Quantitative Tool → Get technical indicators
  2. Call RAG Service → Retrieve market context
  3. LLM Synthesis → Generate investment thesis

Running the Project

Java Server

cd java-tool-server
mvn spring-boot:run

Server will be available at: http://localhost:8080

Python Advisor

python langgraph-advisor/main_advisor.py AAPL

API Endpoints

Health Check

GET http://localhost:8080/ai/tools/health

Technical Indicators

POST http://localhost:8080/ai/tools/technical-indicators
Body: {"ticker": "AAPL"}

Investment Thesis (Java GOAP)

POST http://localhost:8080/ai/agent/thesis
Body: {"ticker": "AAPL"}

Type Safety Comparison

Java (Compile-time verification)

public record ThesisResult(
    String ticker,
    String investmentThesis,
    String recommendation,
    double confidenceScore
) {}

Python (Runtime validation)

class ThesisResult(BaseModel):
    ticker: str
    investmentThesis: str
    recommendation: str
    confidenceScore: float

MCP Protocol

The mcp.json manifest describes available tools and their schemas, enabling:

  • Cross-language tool discovery
  • Type-safe remote procedure calls
  • Hybrid microservice architectures

When to Choose Which

Choose Java/Spring AI for:

  • Production enterprise systems
  • Strict compliance requirements
  • High-concurrency microservices
  • Integration with existing Java infrastructure

Choose Python/LangGraph for:

  • R&D and experimentation
  • Data science integration
  • Rapid prototyping
  • Custom ML model integration

Hybrid Approach (Best of Both):

  • Python orchestration calling Java backend tools
  • Fast development with stable, scalable foundations

About

A comprehensive comparison of two leading approaches to building production-ready LLM agents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors