Annotation Interface OutputFormatSpec


@Documented @Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface OutputFormatSpec
Specifies the output format for structured responses from agents or actions.

Can be applied at:

  • Type level (Role/Agent class): Sets default format for all actions
  • Method level (Action): Overrides the class-level default for specific action

Example usage:

 // Role level - all actions default to YAML
 @OutputFormatSpec(com.tnsai.output.OutputFormat.YAML)
 public class SpecManagerRole extends Role {

     // Inherits YAML from class
     @Action(description = "Get config")
     public Spec getSpec() { ... }

     // Override to CSV for this specific action
     @Action(description = "Export metrics")
     public List<Metric> exportMetrics() { ... }
 }
 
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether to pretty-print the output (where applicable).
    Optional schema hint for formats that support typed schemas (e.g., TONL).
    The output format to use.
  • Element Details

    • value

      The output format to use. Defaults to JSON for maximum compatibility.
      Returns:
      the output format
      Default:
      JSON
    • prettyPrint

      boolean prettyPrint
      Whether to pretty-print the output (where applicable).
      Returns:
      true for pretty-printed output
      Default:
      true
    • schema

      Class<?> schema
      Optional schema hint for formats that support typed schemas (e.g., TONL). When empty, schema is inferred from the return type.
      Returns:
      schema class or empty for auto-inference
      Default:
      java.lang.Void.class