Skip to content

RFC: Naftiko Extension for LangChain4j #293

@jlouvel

Description

@jlouvel

Overview

This RFC proposes a native integration between the Naftiko Framework and LangChain4j. The goal is to provide Java developers with a "Clean Data Layer" for AI agents, allowing them to define tool capabilities in YAML via Naftiko and consume them as type-safe tools in LangChain4j without writing boilerplate integration code.

Problem Statement

Enterprise AI agents often need to interact with legacy systems (SOAP, gRPC, complex REST). Currently, LangChain4j developers must:

  1. Write manual @tool annotated methods for every API.
  2. Handle complex data transformation within the Java code.
  3. Manage "Data Sprawl," where LLMs receive too much irrelevant metadata, increasing token costs and reducing accuracy.

Proposed Solution: NaftikoToolProvider

We propose a bridge module that allows Naftiko to act as a Dynamic Tool Catalog for LangChain4j.

Key Components:

  • Metadata Mapping: A converter that translates Naftiko’s YAML capability definitions into LangChain4j ToolSpecification objects.
  • Context Engineering: Using Naftiko’s spec-driven transformation (JSONPath/Jolt) to ensure the LLM receives only the "right-sized" data needed for the task.
  • Direct Execution: A ToolExecutor that routes LLM-generated arguments directly to the Naftiko engine for execution within the same JVM.

Benefits

  • Low Code: Define enterprise integrations in YAML; use them in Java AI agents instantly.
  • Governance: Centrally manage API keys, rate limits, and data masking in Naftiko.
  • Efficiency: Reduce token usage by filtering API responses before they reach the LLM.

Next Steps

  1. Develop the naftiko-langchain4j bridge library.
  2. Contribute a "Legacy-to-AI" example to the langchain4j-examples repository.
  3. Engage with the community on Discord/GitHub for feedback.

Example

// Loading Naftiko-defined skills directly into an AI Service
NaftikoToolProvider naftikoProvider = new NaftikoToolProvider("classpath:/skills/");

Assistant assistant = AiServices.builder(Assistant.class)
    .chatLanguageModel(model)
    .toolProvider(naftikoProvider) 
    .build();

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions