Annotation Reference
TramAI currently uses a small annotation set.
@AiService
Marks an interface as a TramAI service contract.
Use it on interfaces only.
@AiService
interface Summarizer
@Operation
Declares an AI-backed method.
Fields:
prompt: base user promptmodel: logical model nameprovider: optional explicit provider id overridetools: optional list of tool names available to the operationmaxRetries: structured-output retry countproviderRetries: provider retry count for transient failurestimeoutMillis: per-attempt provider timeout in millisecondscacheable: enables engine-owned caching for successful non-streaming responsescacheTtlMillis: cache lifetime in milliseconds when caching is enabled
Example:
@Operation(
prompt = "Summarize the incident",
model = "gpt-4o",
provider = "openai",
tools = ["lookup"],
maxRetries = 3,
providerRetries = 2,
timeoutMillis = 15_000,
cacheable = true,
cacheTtlMillis = 60_000,
)
@SystemPrompt
Applies a service-wide system prompt to all operations on the interface.
@AiService
@SystemPrompt("You are a precise billing assistant.")
interface BillingAnalyzer
@AiTool
Marks a function, method, or class as a tool that AI models can invoke.
Use on:
- Methods within an
@AiServiceinterface to declare tools - Standalone classes implementing
TramaiToolinterface
Fields:
name: explicit tool name (defaults to method name)description: tool description for model tool definitionsidempotent: safe to retry on transient failure (default:false)sideEffectLevel: side-effect classification —UNKNOWN,NONE,READ_ONLY,MUTATING(default:UNKNOWN)
@AiTool(
name = "lookup_vendor",
description = "Looks up vendor details by ID",
idempotent = true,
)
suspend fun lookupVendor(vendorId: String): Vendor
@AiDescription
Adds a human-readable description to a structured output property or tool parameter.
Useful for:
- clarifying field intent
- making schema prompts less ambiguous
- documenting tool input parameters
@AiRange
Constrains a numeric field.
@property:AiRange(min = 0.0, max = 1.0)
val confidence: Double
@AiMinItems
Constrains collection length.
@property:AiMinItems(1)
val recommendations: List<String>
Current Annotation Behavior
- annotations are runtime-retained
- structured field annotations influence schema generation and validation
- operation annotations influence prompt rendering and routing
Current Behavior Boundaries
TramAI does not currently use dedicated annotations for:
- streaming
- provider-native structured output toggles
Streaming is selected through the return type Flow<StreamChunk>.
Tool calling is enabled through @AiTool annotations and @Operation(tools = [...]) rather than through a single separate annotation.
Conversation state is configured through the tramai-memory module, not through operation-level annotations.
