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
| Annotation | Target | Purpose |
|---|---|---|
ActionSpec | Method | Marks a method as an agent action/tool |
ApprovalRequired | Method | Requires human approval before execution |
invalid reference
| Method/Type | Specifies output serialization format |
CommunicationStyle | Type | Configures 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:
-
ClassDescriptionMarks a method as an executable action that can be discovered and invoked by agents.Marks a method as a post-action handler that runs after the action completes.Defines agent specification including identity and default configuration.Marks an action as requiring human approval before execution.Records method invocations to an audit trail.Marks a method as a pre-processor for an action.The class configuration file an
AgentSpec.config()or aRoleSpec.config()points at, read once per class and run; a host starts a run withClassConfig.useBaseDirectory(java.nio.file.Path).One level of a file: an agent, a role in an agent's file, or a role's own file.A run file as a host passes it toClassConfig.useBaseDirectory(RunFile)andClassConfig.checkAgents(RunFile): its base directory, its name for messages, itsAgentssection and, optionally, the agent types of the run.Configures communication style and messaging for agents and roles.Messaging channel configuration.Communication style settings.Annotation to define agent's communication style.Marks an action as a completion signal that terminates the agent loop.Points an agent or role class at its configuration file.Drops what a module derived from class configuration files whenClassConfig.useBaseDirectory(java.nio.file.Path)starts a new run.Defines behavioral contracts for actions using Design by Contract principles.Defines how contracts are inherited.Configures coordination behavior for multi-agent systems.Consensus mechanism configuration.Negotiation protocol configuration.Negotiation protocol types.Configures W3C Decentralized Identifier (DID) for agent identity.Supported key types for DID cryptography.Defines a structured effect (state modification) for planning.Effect operations for state modification.Marks an action as producing ephemeral outputs that should not accumulate in context.Marks a method or class for evaluation metric collection.Categories for evaluation metrics.Marks a method to automatically emit an event after execution.Event scope definitions.Marks a method as an event handler for agent events.Optional action execution restriction.Fallback handler invoked when the primary agent or tool fails.Defines a goal for planning.Declares agent group memberships.Defines a custom HTTP header for WEB_SERVICE actions.Declares the runtime dispatcher's expectation about idempotency-key tracking for aToolmethod (TNS-299).Marks an action as idempotent, meaning it can be safely retried without causing duplicate side effects.Configures input validation and sanitization for actions.Content categories for moderation.Actions on guardrail failure.Declares a body of knowledge and how it reaches the model.Kinds of corpus a loader can ingest.How a source's content reaches the model.How a source the same spec declares must be present.Whether a source must load when nothing configures it.Marks a method as a lifecycle callback for agent initialization and cleanup.Agent lifecycle phases.Defines a parameter that is exposed to the LLM for tool calling.Container annotation for multipleLLMParamannotations.LLM configuration for Agents and Roles.Supported LLM providers.Configures MCP (Model Context Protocol) tool action execution.Configures memory and state management for agents.Conversation memory configuration.State persistence configuration.Vector memory configuration.Memory configuration annotation for Agents.Memory types.Persistence backends.Pruning strategies.Collects latency, call count, and error rate metrics for a method.Defines a social norm (obligation, prohibition, or permission) for a role.Container for repeatableNormannotations.Types of social norms based on deontic logic.Specifies the output format for structured responses from agents or actions.Configures output validation and formatting for actions.Actions on guardrail failure.Output format types.PII (Personally Identifiable Information) types.Specifies a prompt template file for custom state rendering.Defines an evaluation quality threshold for a method's output.Actions when quality gate fails.Configures resilience policies for actions and roles.Circuit breaker configuration.Rate limiting configuration.Retry policy configuration.Defines role specification for agents.How aKnowledge.Use.SEARCHsource is ranked and rendered.Fallback actions on retrieval failure.Query expansion methods.Retrieval strategies.Configures security policies for actions and roles.Audit logging levels.Classifies the observable effect aToolmethod has on the world (TNS-299).Marks a class as a skill with metadata for routing and discovery.Marks a field as agent state for planning.Marks a method as a tool that an LLM agent can call.Defines an example for a tool/action to help LLMs understand usage patterns.Per-parameter metadata for aTool-annotated method.Adds trace ID propagation and structured logging to a method.Utility-based planning configuration for actions.Overrides the agent's default variant for a specific action.Configures vector memory for an Agent class.Configures web service action execution.