Package com.tnsai.annotations


package com.tnsai.annotations
Custom annotations for the TnsAI framework.

This package contains annotations used to declaratively configure agent behavior, actions, and other framework features.

Available Annotations

AnnotationTargetPurpose
ActionSpecMethodMarks a method as an agent action/tool
ApprovalRequiredMethodRequires human approval before execution
invalid reference
OutputFormat
Method/TypeSpecifies output serialization format
CommunicationStyleTypeConfigures agent communication style

@Action Annotation

Marks methods that can be called as LLM tools:


 @ActionSpec("Search the web for information")
 public String searchWeb(String query) {
     return webSearchService.search(query);
 }

 @ActionSpec(value = "Calculate mathematical expression", name = "calculator")
 public double calculate(String expression) {
     return mathEvaluator.evaluate(expression);
 }
 

@ApprovalRequired Annotation

Marks actions that require human-in-the-loop approval:


 @ActionSpec("Delete user account")
 @ApprovalRequired(reason = "Destructive operation")
 public void deleteUser(String userId) {
     userService.delete(userId);
 }
 

JSON Schema Generation

Annotations are processed at runtime to generate JSON Schema definitions for LLM tool specifications, including:

  • Parameter names (using -parameters compiler flag)
  • Parameter types mapped to JSON Schema types
  • Description from @Action annotation

Requirements

For parameter name reflection to work, compile with:


 <compilerArgs>
     <arg>-parameters</arg>
 </compilerArgs>
 
See Also: