giuseppe-trisciuoglio avatar

Langchain4j Tool Function Calling Patterns

This one teaches you how to wire up external function calls in LangChain4j agents using the @Tool annotation system. You annotate methods with @Tool and @P, register them with AiServices.builder().tools(), and the LLM can invoke them during conversations. The skill covers error handlers for when the model hallucinates tool names or passes bad arguments, concurrent execution for independent tools, and timeout configs for external API calls. It's practical if you're building agents that need to query databases, hit APIs, or perform calculations beyond what the LLM can do natively. The examples show calculator tools, email senders with immediate return behavior, and dynamic tool providers that change based on user context.

skills.sh installs
3.9K
GitHub stars
369
last updated
Aug 21, 2026

Install

$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill langchain4j-tool-function-calling-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/giuseppe-trisciuoglio/developer-kit
Category
AI & Agent Building
First seen
May 16, 2026

More from giuseppe-trisciuoglio/developer-kit

All 102
1giuseppe-trisciuoglio avatarsonarqube-mcpgiuseppe-trisciuoglio/developer-kitProvides SonarQube and SonarCloud integration patterns via the Model Context Protocol (MCP) server. Enables quality gate monitoring, issue discovery and triagin3.7Kskills.sh installs
2paperclipai avatarpaperclip-create-agentpaperclipai/paperclipCreate new agents in Paperclip with governance-aware hiring. Use when you need to inspect adapter configuration options, compare existing agent configs, draft a3.6Kskills.sh installs
3arize-ai avatararize-prompt-optimizationarize-ai/arize-skillsOptimizes, improves, and debugs LLM prompts using production trace data, evaluations, and annotations. Extracts prompts from spans, gathers performance signal, 3.4Kskills.sh installs
4nvidia avatarrag-blueprintnvidia/skillsNVIDIA RAG Blueprint — deploy, configure, troubleshoot, and manage. Handles any RAG action: deploy, install, start, enable, disable, toggle, change, configure, 3.4Kskills.sh installs
5wshobson avatarai-debt-detectorwshobson/agentsUse after generating code, after accepting AI suggestions, or when reviewing AI-written modules. Also use when code works but feels brittle, when error handling3.4Kskills.sh installs
6starchild-ai-agent avatarvideostarchild-ai-agent/official-skillsAI video generation: text-to-video, image-to-video, video-to-video, model selection. Use when generating a short video clip from a prompt or reference (e.g. 5s 2.7Kskills.sh installs