Package com.tnsai.roles.annotations
Annotation 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 -
Optional Element Summary
Optional Elements
-
Element Details
-
name
String nameThe unique name identifying this role.If not specified, defaults to the simple class name without "Role" suffix.
- Returns:
- role name
- Default:
""
-
goal
String goalThe 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 domainThe domain or area of expertise for this role.Provides context about the role's specialty.
- Returns:
- domain name (optional)
- Default:
""
-
description
String descriptionA longer description of the role.Used for documentation and exported to framework-specific backstory fields.
- Returns:
- role description (optional)
- Default:
""
-
version
String versionVersion of this role definition.Useful for tracking changes and compatibility.
- Returns:
- semantic version string (e.g., "1.0.0")
- Default:
"1.0.0"
-