Install any skill in seconds. Free to start, no credit card required.
Get Started Free →giuseppe-trisciuoglio/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.
Passed 21 of 22 test cases with the skill, and 13 of 22 without it.
and 8 more in the full report
8 fixed13 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 8 test cases the skill fixed. Same model, same prompt, with and without the skill.
We are developing a multi-user Java application with LangChain4j where tool execution needs to access the specific calling user's ID without forcing the user to state their ID in chat messages. What LangChain4j annotation injects the session or user identifier directly into a tool method parameter?
| Checked | Without skill | With skill |
|---|---|---|
| Uses @ToolMemoryId on a tool method parameter to receive the user or session identifier | Missed | Passed |
The instructions your model reads when the skill loads.
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.
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.
@Tool, @P annotations)AiServices.builder().tools()@ToolMemoryId@ToolDefine 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);
}
}
test cases passed, vs 13 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.