
Langchain4j Tool Function Calling Patterns
Java tool-calling patterns for LangChain4j that register methods with AiServices and handle execution failures.
- skills.sh installs
- 3.9K
- GitHub stars
- 372
- last updated
- Aug 21, 2026
What it does
- Covers
@Tooland@Pannotation usage, tool registration withAiServices.builder().tools(), and dynamicToolProvidersetups - Includes error handling hooks such as
toolExecutionErrorHandler,hallucinatedToolNameStrategy, andtoolArgumentsErrorHandler, plus concurrency and timeout options - Enforces safe failure behavior by returning user-friendly error strings instead of stack traces, and keeping credentials out of tool descriptions
- Designed for Java developers building LLM-driven agents that call external APIs, databases, or business systems
Install
$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill langchain4j-tool-function-calling-patterns -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
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,@Pannotations) - 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
Details
- Repository
- github.com/giuseppe-trisciuoglio/developer-kit
- Categories
- AI Agents & LLM Apps, Java & JVM
- First seen
- May 16, 2026
More from giuseppe-trisciuoglio/developer-kit
All 95- Langchain4j Rag Implementation Patterns3.9K
- Unit Test Scheduled Async3.9K
- Rag3.9K
- Unit Test Utility Methods3.9K
- Qdrant3.9K
- Unit Test Exception Handler3.9K
- Unit Test Mapper Converter3.9K
- Langchain4j Ai Services Patterns3.9K
- Unit Test Caching3.9K
- Unit Test Config Properties3.9K
- Unit Test Application Events3.9K
- Langchain4j Vector Stores Configuration3.9K
- Langchain4j Mcp Server Patterns3.9K
- Aws Sdk Java V2 S33.9K
- Langchain4j Testing Strategies3.9K
- Aws Sdk Java V2 Dynamodb3.9K
- Aws Rds Spring Boot Integration3.9K
- Nextjs Deployment3.9K
- Aws Sdk Java V2 Lambda3.9K
- Aws Sdk Java V2 Core3.9K
- Aws Sdk Java V2 Bedrock3.9K
- Aws Sdk Java V2 Messaging3.9K
- Aws Sdk Java V2 Secrets Manager3.9K
- Aws Sdk Java V2 Kms3.9K
Similar to Langchain4j Tool Function Calling Patterns
More AI Agents & LLM Apps
langchain4j-ai-services-patternsgiuseppe-trisciuoglio/developer-kit3.9K installsDeclarative Java AI service patterns for LangChain4j, covering interface-based prompts, memory, and tool calling.
langchain4j-mcp-server-patternsgiuseppe-trisciuoglio/developer-kit3.9K installsJava patterns for building MCP servers and wiring LangChain4j tools with trust-based filtering and fail-closed defaults.
agent-tool-buildersickn33/agentic-awesome-skills826 installsSchema and description design guide for agent tools, including JSON Schema, validation, and MCP.
toolslaunchdarkly/ai-tooling1.3K installsConfig tools: attach function-calling tool definitions to LaunchDarkly agent config variations and wire up their handlers.
llm-app-patternssickn33/agentic-awesome-skills700 installsArchitecture sketches for LLM apps with explicit retrieval, tool, privacy, and verification boundaries.