SkillsReviewed · giuseppe-trisciuoglio

LangChain4j Tool & Function Calling Patterns

LangChain4j Tool & Function Calling Patterns is an assistant skill for Java developers connecting AI models to application functions, but its examples use inconsistent API forms without specifying compatible library versions. It covers annotated methods, tool registration, argument handling, streaming and context-based tool selection.

Researched 17 Nov 2026

In short.

LangChain4j Tool & Function Calling Patterns is an assistant skill for Java developers adding tool calls to AI applications, but its examples need version checks and corrections before use. The basic annotated-method and AiServices registration patterns provide a clear starting point. Advanced examples disagree on API signatures, setup lacks dependency versions, and several security examples omit actual authorization. No code was executed; compilation, tool-call reliability, performance and production suitability are not assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Covers plugins/developer-kit-java/skills/langchain4j-tool-function-calling-patterns/SKILL.md and all eight captured reference files: advanced-features.md, core-patterns.md, error-handling.md, examples.md, implementation-patterns.md, integration-examples.md, references.md and setup-configuration.md. The repository-root LICENSE provides the related MIT notice. Other developer-kit skills, linked external documentation, dependencies and provider services are outside this scope. No code was executed; installation, compilation, runtime behavior, provider compatibility, performance and security remain unassessed.

The overview

Identity

The skill belongs to Giuseppe Trisciuoglio's developer-kit repository, in plugins/developer-kit-java/skills/langchain4j-tool-function-calling-patterns. Its deliverable is SKILL.md plus eight Markdown reference files containing Java examples. The entry point describes guidance an assistant can use when generating LangChain4j tool-calling code.

The original source folder is [https://github.com/giuseppe-trisciuoglio/developer-kit/tree/main/plugins/developer-kit-java/skills/langchain4j-tool-function-calling-patterns]. This report concerns that skill folder and its accompanying repository licence.

Assessment

Useful as a pattern reference for exposing Java application functions to an AI model. Its progression from calculator methods to dynamic tools, streaming and external services gives developers concrete topics to explore.

The examples.md description of the examples as production-ready is unsupported by the supplied material. There are incomplete dependencies, conflicting API forms and a clear return-type mismatch in the customer-support example. Treat the snippets as implementation starting points requiring correction and verification.

Who it suits

The closest fit is a Java developer building an assistant that queries application data, calls an external API or performs a business operation. Developers already using LangChain4j can use the material to identify patterns for registration, context handling and failures.

Beginners can follow the calculator examples, but will need enough Java knowledge to supply imports, dependencies and missing services. Spring application developers get controller, repository and HTTP-client examples, although those integrations require additional implementation.

What it covers

The documents cover defining tools with @Tool, describing arguments with @P, registering tool objects through AiServices, validating inputs and returning simple or structured values. They also illustrate argument errors, execution failures, nonexistent tool names, timeouts, retries and circuit breakers.

Advanced topics include @ToolMemoryId context injection, dynamic ToolProvider implementations, programmatic tool specifications and executors, streaming callbacks, concurrent execution and AI services exposed as tools. These are documented patterns; working support across particular library and model versions is unknown.

Using it

Requirements

Implementing the examples requires a Java development environment, suitable LangChain4j dependencies and a configured chat model with appropriate tool-calling support. Provider examples read credentials from environment variables, including OPENAI_API_KEY and HUGGINGFACE_API_KEY.

Minimum JDK requirements, dependency coordinates, library versions and a supported-model matrix are unspecified. Advanced examples assume repositories, HTTP clients, Spring components, metrics facilities and resilience utilities that are not fully supplied. Compatible assistant hosts and skill-installation requirements are also unknown.

How the patterns work

Tool calling lets an AI model request an application function using a tool name and arguments. The Java application executes the matching method and makes its result available for the model's response.

In these examples, @Tool exposes a method, @P describes its arguments, and AiServices.builder(...).tools(...) registers tool objects. Dynamic providers select available tools from context, while @ToolMemoryId supplies a conversation or user identifier. Those identifiers and descriptions still require application-level validation and permission checks.

Getting started

The documented starting sequence is to define a calculator class, annotate a method, create an assistant interface, configure a chat model and register the calculator through AiServices. setup-configuration.md also illustrates error handlers, conversation memory and concurrent execution.

Before copying the code, choose a LangChain4j version and reconcile the examples with that version's APIs. The supplied setup contains configuration snippets but no dependency declarations or complete build instructions. Instructions for installing the folder into a particular assistant are not provided.

A concrete example

examples.md defines Calculator.add(int a, int b), registers a Calculator instance with a CalculatorAssistant and configures an OpenAiChatModel using OPENAI_API_KEY. Its sample question asks for the sum of 25 and 37.

The intended flow is for the model to select add, supply the two numbers and use the returned value in its reply. The expected arithmetic answer is 62. No actual model response or tool-execution trace accompanies the example, and nothing was executed.

Assessment & evidence

Limitations

The documents disagree on API forms. SKILL.md uses ReturnBehavior.IMMEDIATELY, while advanced-features.md uses ReturnBehavior.IMMEDIATE. ToolProvider examples alternate between returning lists of objects and returning ToolProviderResult from a ToolProviderRequest. Error-handler return types and streaming callback names also vary. Compatible versions for these forms are unspecified.

integration-examples.md assigns the result of a String-returning SupportAssistant.chat method to Result<String>, creating a visible type mismatch. Other snippets contain unresolved services or simulated data, so they do not establish working database or API integrations.

The authorization example validates an identifier's format without showing a permission check. Payment and customer-update snippets also show no authorization or protection against repeated calls. Some error handlers return raw exception messages despite the guidance to provide safe errors. Security and operational suitability remain unassessed.

Engineering considerations

The useful design principle is to keep model-facing tool descriptions separate from the Java code that enforces valid operations. Dynamic tool selection can narrow the available functions, while authorization and input rules still belong inside the application.

The skill's thread-safety warning matters because its examples include a mutable preference map and counter. Combining those examples with concurrent execution requires additional state management. Likewise, the supplied validation helper accepts a response based on its text; that alone does not demonstrate that the intended tool executed or produced the correct result.

Related resources

The skill links to LangChain4j's tools documentation [https://docs.langchain4j.dev/features/tools] and examples repository [https://github.com/langchain4j/langchain4j-examples]. These are relevant next references for resolving API questions, although their contents and compatibility were not assessed here.

SKILL.md also names related skills for AI services, retrieval-augmented generation and Spring Boot integration. Those may address adjacent implementation needs, but their files are outside this resource's supplied scope.

Evidence and its limits

The available source includes the entry-point skill, eight reference documents and the repository-root MIT notice. Together they establish the documented patterns, example code and reuse terms.

The material contains proposed validation steps and a validation-helper sketch, but no execution logs, compiler results, verified integration traces, security assessment or measured benchmarks. Descriptions such as production-ready and comments claiming deterministic behavior are not established by supplied results.

Access & freshness

Costs

No purchase price for the skill or operating-cost estimate is stated. The model examples require provider credentials, and integrations can involve additional external services.

Provider charges, hosting requirements, rate limits and total operating costs are unknown from the supplied material. There are no measured token-usage or cost results.

Licence and reuse

The repository-root MIT licence names Giuseppe Trisciuoglio as the 2025 copyright holder. It permits use, copying, modification, distribution, sublicensing and sale of the software and associated documentation, provided the copyright and permission notices accompany copies or substantial portions.

The licence disclaims warranty and liability. Its notice is available at [https://raw.githubusercontent.com/giuseppe-trisciuoglio/developer-kit/fe73fb33a09ee6562eeec7415a3f9a3bcf795177/LICENSE]. Separate terms for model providers, external services and dependencies are not established by this notice.

Version and freshness

The supplied snapshot is fixed at repository revision fe73fb33a09ee6562eeec7415a3f9a3bcf795177 and was captured on 2026-11-17 at 08:02:00.719 UTC.

No supported LangChain4j release or per-document update date is supplied. The examples use both ChatLanguageModel and ChatModel alongside differing tool APIs. Which forms match a developer's chosen release, and whether later upstream changes resolve the differences, are unknown.

Before adopting it

Choose and pin a LangChain4j version, resolve the conflicting API forms and complete the missing dependencies. Begin with the calculator example and verify both the actual tool invocation and its result.

Before connecting tools to real data or business operations, implement permission checks, input validation, repeat-call protection and safe error responses. Set external-call timeouts, check mutable state before enabling concurrency, and verify malformed arguments, nonexistent tools and service failures.

Evidence for this report

LICENSEnotice · checked 2026-11-17