langchain4j-tool-function-calling-patterns

Define and call LangChain4j tools with @Tool annotations and ToolProvider.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/rizaldiem/digital-invitation-web_V2 --skill langchain4j-tool-function-calling-patterns-rizaldiem
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: langchain4j-tool-function-calling-patterns
Source: https://github.com/rizaldiem/digital-invitation-web_V2/tree/main/.windsurf/skills/langchain4j-tool-function-calling-patterns
Command: npx skills add https://github.com/rizaldiem/digital-invitation-web_V2 --skill langchain4j-tool-function-calling-patterns-rizaldiem

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Building AI agents with LangChain4j often requires a clear, reusable pattern to define tools and external function calls, enabling seamless integration with APIs, databases, and services.

Core Features & Use Cases

  • Define tools with @Tool and describe parameters with @P to guide LLM interactions.
  • Dynamically provision tools at runtime using ToolProvider to adapt to user context.
  • Support advanced patterns like memory-aware tools, streaming tool execution, and robust error handling.

Quick Start

Create a simple tool class with annotated methods, register it with AiServices, and prompt your agent to call the tool.

Frequently Asked Questions about langchain4j-tool-function-calling-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define custom tools for AI agents in LangChain4j?

To define custom tools for AI agents in LangChain4j, you create a tool class with methods annotated with @Tool and describe parameters using @P, then register the class with AiServices to enable automated interactions with external systems.

What is the best way to dynamically provision LangChain4j tools at runtime?

Dynamically provisioning LangChain4j tools at runtime is handled by the ToolProvider interface, which allows your AI agents to adapt tool availability to the specific user context and request parameters during execution.

How does function calling handle external API errors in LangChain4j?

Function calling in LangChain4j handles external API errors through robust error handling hooks, allowing your AI agents to manage failures across APIs, databases, and services gracefully during tool execution.

Can I integrate chat memory with tool execution in LangChain4j?

Yes, you can integrate chat memory with tool execution in LangChain4j by using memory-aware tools, ensuring that AI agents retain conversational context while dynamically calling functions and external services.

Does LangChain4j support streaming responses during tool execution?

Yes, LangChain4j supports streaming tool execution, enabling AI agents to process and stream responses dynamically while interacting with external systems using the ToolProvider and annotated functions.

When should I use ToolProvider instead of @Tool annotations in LangChain4j?

You should use ToolProvider instead of @Tool annotations in LangChain4j when your agentic application requires dynamic tool discovery and runtime provisioning to adapt to changing user contexts, rather than static method definitions.