The @Tool annotation marks a method that an LLM may invoke through LangChain4j function calling. Its natural-language description helps the model match a user instruction to the appropriate method. A different prompt may cause the tool not to run. section 9.2.1 section 9.4
Annotating database assistant operations
A tool class can expose focused operations such as @Tool("Create room records") on createRooms, @Tool("Create booking records") on createBookings, and @Tool("Show results of database") on displayDatabase. With these tools registered in AiServices, a prompt such as “Can you create me 4 rooms and 2 bookings and tell me what’s in the db” can lead the agent to call the matching methods. Use @P descriptions on parameters such as count to help pass extracted prompt values into the methods. section 9.2.1 section 9.4
public class DataAssistantTools {
@Tool("Create room records")
public void createRooms(@P("Amount of room records to create")
➥int count) {
System.out.println("You want me to create " + count + "
➥rooms.");
}
@Tool("Create booking records")
public void createBookings(@P("Amount of booking records to
➥create") int count) {
System.out.println("You want me to create " + count + "
➥bookings.");
}
@Tool("Show results of database")
public void displayDatabase() {
System.out.println("I'll then share current database
➥details");
}
}
Shows the annotation on three Java methods, including natural-language descriptions and @P parameter metadata. section 9.2.1

