Annotation Interface Agent
When package scanning is enabled on AgenorRuntime, all classes annotated
with @Agent are discovered, instantiated, and registered in the
AgentDirectory. The runtime then calls start() on
each agent that has autoStart() set to true.
Example usage:
@Agent(value = "order-processor", type = "processor",
capabilities = {"order.processing", "inventory.check"})
public class OrderProcessorAgent extends BaseAgent {
@Behavior(type = CYCLIC, interval = "10s")
public void processPendingOrders() { ... }
}
- Since:
- 0.1.0
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether the runtime should start this agent automatically after registration.String[]Capability identifiers advertised by this agent.An optional type label used for grouping and querying agents.The agent identifier used for registration and discovery.
-
Element Details
-
value
String valueThe agent identifier used for registration and discovery.The value must be unique within the runtime: it is the address the agent is sent messages at, registered in the directory under, and published as the sender of its own messages. A class annotated with a fixed id and instantiated twice therefore produces two agents claiming one address.
When left empty,
BaseAgentgenerates a random UUID — which is also what an agent gets when it is not annotated at all. There is no class-name default. This Javadoc promised one, in kebab-case, until 0.34.0; nothing ever implemented it, and a default derived from the class would give every instance of a class the same address.A subclass that passes its own id to
super(...)overrides this value, because an explicit instance id is the authoritative one — that is how an agent class instantiated several times gets distinct addresses.- Returns:
- the agent identifier, or empty string for a generated one
- Default:
""
-
type
String typeAn optional type label used for grouping and querying agents.Types allow callers to query the
AgentDirectoryfor all agents of a given type (e.g.,"processor","collector","monitor"). The type has no effect on agent behavior.- Returns:
- the agent type label, or empty string if not categorized
- Default:
""
-
capabilities
String[] capabilitiesCapability identifiers advertised by this agent.Capabilities are arbitrary strings that describe what this agent can do (e.g.,
"order.processing","report.generation"). Other agents can query the directory to find agents with specific capabilities.- Returns:
- declared capability strings, empty array if none
- Default:
{}
-
autoStart
boolean autoStartWhether the runtime should start this agent automatically after registration.Set to
falsefor agents that should be started manually or on demand. Defaults totrue.- Returns:
trueto start automatically,falsefor manual start
- Default:
true
-