LogoAwesome Skills
  • Search
  • Category
  • Tag
  • Blog
LogoAwesome Skills
LogoAwesome Skills

Discover Open-Source Agent Skills for AI Coding Assistants

Product

  • Search
  • Category
  • Tag
  • Blog

Resources

  • Claude Skill Docs
  • Antigravity Skills Docs

Tools

  • Claude Code
  • OpenCode
  • Cursor
  • Codex
  • Antigravity

Company

  • Privacy Policy
  • Terms of Service
  • Sitemap

©2026 Awesome Skills. All rights reserved.

Privacy PolicyTerms
Back to Skills

langchain4j-tool-function-calling-patterns

Provides and generates LangChain4j tool and function calling patterns: annotates methods as tools with @Tool, configures tool executors, registers tools with AiServices, validates tool parameters, and handles tool execution errors. Use when building AI agents that call tools, define function specifications, manage tool responses, or integrate external APIs with LLM-driven applications.

314stars37forksUpdated 7/31/2026
Developer Tools#function-calling#code-generation#langchain4j#ai-agents#java#llm

Security Assessment

Safe(93/100)
Security Score93/100

About langchain4j-tool-function-calling-patterns

LangChain4j Tool & Function Calling Patterns is a Java coding-guidance skill that provides and generates the patterns needed to give LLM-driven applications the ability to call tools. It solves the problem of correctly exposing Java methods as callable functions for AI agents using LangChain4j — annotating methods with @Tool and parameters with @P, registering tool sets through the AiServices builder, and handling the failure modes that come with LLM tool use, such as execution errors, malformed arguments, and hallucinated tool names.

The skill delivers a step-by-step workflow with validation checkpoints: annotate a tool class, register it with a chat model via AiServices.builder().tools(), test end-to-end that a prompt actually triggers the tool, add error handlers that return safe messages instead of leaking stack traces, and optimize for scale with concurrent execution and per-tool timeouts. Extensive reference files cover core patterns, implementation patterns, advanced features (context-aware tools via @ToolMemoryId, dynamic tool providers for large or conditional tool sets), setup and configuration, integration examples, error handling, and practical end-to-end examples including calculators, multi-domain tool selection, structured return types, and a database example that validates queries are read-only SELECT statements before executing.

It targets Java developers building AI agents and LLM integrations who want production-ready, defensively coded tool-calling patterns. Use cases include wiring external APIs (weather, stocks), database lookups, and calculations into an assistant, managing multiple tool domains, and hardening tool execution against timeouts and bad input. The examples read API keys from environment variables, following standard credential practice.

FAQ

What framework and language does this target?

Java applications using the LangChain4j framework, specifically its @Tool and @P annotations and the AiServices builder for registering tools with a chat model.

How are tools defined and registered?

You annotate methods with @Tool (with a description) and parameters with @P, then register tool instances via AiServices.builder().chatModel(...).tools(...).build().

How does it handle tool execution failures?

It shows toolExecutionErrorHandler, toolArgumentsErrorHandler, and a hallucinatedToolNameStrategy so failures, invalid arguments, and non-existent tool names return safe messages to the LLM rather than exposing stack traces.

Can it scale to many concurrent or slow tools?

Yes. It documents executeToolsConcurrently with a thread pool and toolExecutionTimeout for long-running tools, with a validation step to confirm no thread contention or deadlocks.

How are API keys handled in the examples?

Example chat models read the provider API key from an environment variable (System.getenv), which is standard credential practice with no hardcoded secrets.

All Files

9 files
references/examples.md16.0 KB
View
SKILL.md9.2 KB
View
references/implementation-patterns.md14.2 KB
View
references/core-patterns.md2.2 KB
View
references/references.md9.3 KB
View
references/advanced-features.md2.3 KB
View
references/integration-examples.md5.1 KB
View
references/error-handling.md2.9 KB
View
references/setup-configuration.md2.0 KB
View

Install langchain4j-tool-function-calling-patterns

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

giuseppe-trisciuoglio/developer-kit

Related Skills

dbt-sf-to-bq-translator

21,076

build-models

102

html-prototype

3,588

doc

448