Annotation Interface RoleDeclaration


@Documented @Retention(RUNTIME) @Target(TYPE) public @interface RoleDeclaration
Defines the identity metadata for a Role class.

This annotation provides a declarative way to define role identity, replacing the need to override getIdentity() method in Role subclasses.

Usage Example


 @RoleDeclaration(
     name = "Researcher",
     goal = "Find and analyze academic information",
     domain = "Research",
     description = "Expert in literature review and synthesis",
     version = "1.0.0"
 )
 public class ResearcherRole extends Role {
     // No need to override getIdentity()
 }
 

Migration from Template Methods

Before (template method):


 public class MyRole extends Role {
     @Override
     public RoleIdentity getIdentity() {
         return new RoleIdentity("MyRole", "Do something", "Domain");
     }
 }
 

After (annotation):


 @RoleDeclaration(name = "MyRole", goal = "Do something", domain = "Domain")
 public class MyRole extends Role { }
 

Framework Interoperability

This annotation can be exported to various agent frameworks:

  • JASON: Agent name and initial goals
  • JADE: Agent description and ontology
  • SCOP: Role plugin metadata
  • LangChain: Agent description and system prompt
  • CrewAI: Agent role and backstory
Author:
TnsAI Team
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The primary goal or objective of this role.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    A longer description of the role.
    The domain or area of expertise for this role.
    The unique name identifying this role.
    Version of this role definition.
  • Element Details

    • name

      String name
      The unique name identifying this role.

      If not specified, defaults to the simple class name without "Role" suffix.

      Returns:
      role name
      Default:
      ""
    • goal

      String goal
      The primary goal or objective of this role.

      Describes what the role is meant to achieve. Required - must be explicitly set.

      Returns:
      role goal
    • domain

      String domain
      The domain or area of expertise for this role.

      Provides context about the role's specialty.

      Returns:
      domain name (optional)
      Default:
      ""
    • description

      String description
      A longer description of the role.

      Used for documentation and exported to framework-specific backstory fields.

      Returns:
      role description (optional)
      Default:
      ""
    • version

      String version
      Version of this role definition.

      Useful for tracking changes and compatibility.

      Returns:
      semantic version string (e.g., "1.0.0")
      Default:
      "1.0.0"