langchain4j-tool-function-calling-patterns

langchain4j-tool-function-calling-patterns is a skill for Claude Code from giuseppe-trisciuoglio/developer-kit. It costs 82 tokens per session (2,027 once invoked), scanned A, original, MIT.

LangChain4j patterns for letting a language model call Java methods as tools or functions. They cover describing tool parameters, registering tools with an AI service, and handling invalid names, errors, and timeouts.

In plain words
What is it for?
Use it to build tool-using agents, expose Java methods, register fixed or dynamic tool sets, pass user context to tools, and handle tool execution failures.
Why use it?
They give an AI application a controlled way to perform actions such as database queries, calculations, or API calls instead of only generating text. Clear parameter descriptions and validation reduce ambiguous or unsafe tool requests.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the developer-kit-java plugin — 52 skills, 11 commands, 9 agents shipped together

Good fit Use it to build tool-using agents, expose Java methods, register fixed or dynamic tool sets, pass user context to tools, and handle tool execution failures.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/giuseppe-trisciuoglio/developer-kit/langchain4j-tool-function-calling-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add giuseppe-trisciuoglio/developer-kit --skill langchain4j-tool-function-calling-patterns
Clone the repo
git clone --depth 1 https://github.com/giuseppe-trisciuoglio/developer-kit

Made for: Claude Code.

Or install developer-kit-java, the plugin that ships this one along with the rest of its 52 skills, 11 commands, 9 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for langchain4j-tool-function-calling-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-tool-function-calling-patterns/github.svg)](https://agentmods.dev/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-tool-function-calling-patterns)
Your own site
<a href="https://agentmods.dev/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-tool-function-calling-patterns"><img src="https://agentmods.dev/badge/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-tool-function-calling-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for langchain4j-tool-function-calling-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-tool-function-calling-patterns"><img src="https://agentmods.dev/badge/skills/giuseppe-trisciuoglio/developer-kit/langchain4j-tool-function-calling-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,027 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 1 Apr 2026
  • Snyk warn 1 Apr 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00082 $0.02027
Opus 5 $0.00041 $0.01014
Sonnet 5 $0.00016 $0.00405
Haiku 4.5 $0.00008 $0.00203

Measured today against content hash 6cd8ae417473, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

langchain4j-tool-function-calling-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/developer-kit-java/skills/langchain4j-tool-function-calling-patterns/SKILL.md · 219 lines

How it starts

The opening of the file, as written. The whole thing — 219 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LangChain4j Tool & Function Calling Patterns

Provides patterns for annotating methods as tools, configuring tool executors, registering tools with AI services, validating parameters, and handling tool execution errors in LangChain4j applications.

Overview

LangChain4j uses the @Tool annotation to expose Java methods as callable functions for AI agents. The AiServices builder registers tools with a chat model, enabling LLMs to perform actions beyond text generation: database queries, API calls, calculations, and business system integrations. Parameters use @P for descriptions that guide the LLM.

When to Use

  • Building AI agents that call external tools (weather, stocks, database queries)
  • Defining function specifications for LLM tool use (@Tool, @P annotations)
  • Registering and managing tool sets with AiServices.builder().tools()
  • Handling tool execution errors, timeouts, and hallucinated tool names
  • Implementing context-aware tools that inject user state via @ToolMemoryId
  • Configuring dynamic tool providers for large or conditional tool sets

Instructions

1. Annotate Methods with @Tool

Define a tool class with methods annotated @Tool. Provide a description as the first parameter. Use @P for each parameter description.

public class WeatherTools {
    private final WeatherService weatherService;

    public WeatherTools(WeatherService weatherService) {
        this.weatherService = weatherService;
    }

    @Tool("Get current weather for a city")
    public String getWeather(
            @P("City name") String city,
            @P("Temperature unit: celsius or fahrenheit") String unit) {
        return weatherService.getWeather(city, unit);
    }
}

Validate: Create an instance and confirm the class loads without errors.

2. Register Tools with AiServices

Use AiServices.builder() to register tool instances with the chat model.

MathAssistant assistant = AiServices.builder(MathAssistant.class)
    .chatModel(chatModel)
    .tools(new Calculator(), new WeatherTools(weatherService))
    .build();

Read the full file on GitHub · 219 lines

Files

What ships with it

8 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 219 lines · 82 tokens per session scan A 6cd8ae417473

Subscribe to this mod's changes

langchain4j-tool-function-calling-patterns is a skill published in the GitHub repository giuseppe-trisciuoglio/developer-kit (343 stars, last pushed yesterday), licensed MIT. It adds 82 tokens to every session and 2,027 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-10.

Related

Other skills, from other repositories

loom-prompt-engineering

Designs and optimizes prompts for large language models including system prompts, agent signals, and few-shot examples.

cosmix/loom · 28 tokens

metaprompt

Generate a complete, ready-to-use prompt for a target model and harness. Triggers: metaprompt, generate a prompt for, write me a prompt, create a system prompt, prompt engineer this, optimize this prompt.

JairoTorregrosa/jaiskills · 48 tokens

improve-prompt

Critique and rewrite a prompt using prompt engineering best practices: clarity, examples, XML structure, role, explicit output format, and positive-over-negative instructions. Asks 1-3 targeted questions to fill missing context, then returns a short critique plus a drop-in rewritten prompt. Use when the user wants to…

tomimor/skills · 80 tokens

write-a-prompt

Creates a copy-ready prompt from a rough request, notes, source material, or the current conversation using OpenAI's prompting guidance. Use when the user invokes $write-a-prompt or /write-a-prompt, types a common misspelling such as /write-a-promopt or /wite-a-prompt, asks to "write a prompt for me," asks to turn the…

bastos/skills · 113 tokens

add-ai

Use when adding an AI/LLM feature to a product - chat, generation, summarization, extraction, semantic search - or when the user says add AI, use Claude, chatbot, embeddings.

T4LEL/Claude-Arsenal · 43 tokens

agent-orchestration-improve-agent

Systematic improvement of existing agents through performance analysis, prompt engineering, and continuous iteration.

lingxling/awesome-skills-cn · 25 tokens