Class ActionMetadata
@ActionSpec annotation via reflection.
Type-specific configuration is read from nested annotations:
@WebService— forWEB_SERVICEactions@MCPTool— forMCP_TOOLactions
For LLM actions, optional per-action overrides
(llmSystemPrompt, llmTemperature) are read directly from
@ActionSpec. Tool exposure is configured at the agent level via
AgentBuilder.builtInTools(...) / .toolPojos(...); the
dispatcher routes any @Tool method calls the LLM emits without
requiring per-action declaration.
Following ADR-006: Immutable Models
- Method name = Action name
- Method signature = Action parameters
@ActionSpecannotation is MANDATORY for action discovery- Annotation provides action type and configuration
-
Constructor Summary
ConstructorsConstructorDescriptionActionMetadata(Method method, List<ParamSpec> parameters) Creates action metadata from a method.ActionMetadata(String name, String description, ActionType type, List<ParamSpec> parameters, ActionHandler handler) Creates action metadata for a programmatically-defined action (TNS-551) — no reflectiveMethod; dispatch goes through the suppliedActionHandler.ActionMetadata(String name, String description, ActionType type, List<ParamSpec> parameters, ActionHandler handler, ContractSpec contractSpec) AsActionMetadata(String, String, ActionType, List, ActionHandler)but with a declarativeContractSpec(TNS-637) — the programmatic equivalent of@Contractfor builder-added actions.ActionMetadata(String name, String description, ActionType type, List<ParamSpec> parameters, ActionHandler handler, ContractSpec contractSpec, InputGuardrailConfig inputGuardrailConfig, OutputGuardrailConfig outputGuardrailConfig) AsActionMetadata(String, String, ActionType, List, ActionHandler, ContractSpec)but also carrying per-action programmatic guardrails (TNS-643) — the builder equivalent of method-level@InputGuardrail/@OutputGuardrail, for builder-added actions that have no method to read the annotation from. -
Method Summary
Modifier and TypeMethodDescriptionReturns a grouped view of all contract and planning configuration.Gets the accept header value.Gets the API key header name for API_KEY auth.Gets the content type for web service requests.Effect[]Gets the effects defined for this action.Gets the endpoint URL for WEB_SERVICE or MCP_TOOL actions.Gets all usage examples (positive and negative) in declaration order.String[]Gets the goals that this action fulfills.Gets the per-action LLM system-prompt override.floatGets the per-action LLM temperature override.Gets the MCP API key environment variable name.intGets the MCP cache TTL in seconds.Header[]Gets the MCP custom headers.intGets the MCP retry backoff.intGets the MCP retry count.Gets the MCP server URL for MCP_TOOL actions.String[]Gets the MCP stdio arguments.Gets the MCP stdio command.String[]Gets the MCP stdio environment variables.intGets the MCP request timeout.Gets the specific MCP tool name.String[]Gets the mustAlways liveness guarantees for this action.String[]Gets the mustNever safety constraints for this action.Gets the negative (bad) examples.getParameter(int position) Gets a parameter by position.intGets the parameter count.List<?> Gets the parameters to expose to LLM.Gets the positive (good) examples.Gets the postcondition expression.Gets the precondition expression.intGets the retry backoff time in ms.intGets the retry count for web service.Gets the simple return type name (without package).Gets the fallback variant for this action.Gets the variant override for this action, if specified.Gets the reason for the variant override.booleanChecks if this action has a description.booleanChecks if this action has usage examples defined.booleanChecks if this action fulfills any goals.booleanChecks if this action has an idempotency key defined.booleanChecks if this action has custom LLM parameters defined.booleanChecks whether a per-action LLM system-prompt override is present.booleanChecks whether a per-action LLM temperature override is present.booleanChecks if this action has any mustAlways constraints.booleanChecks if this action has any mustNever constraints.booleanChecks if this action has parameters.booleanChecks if this action has a postcondition defined.booleanChecks if this action has a precondition defined.booleanChecks if this action has a variant override.booleanChecks if effects should be automatically applied after action execution.booleanChecks if this is a direct code action.booleanChecks if this action is excluded from LLM tool list.booleanChecks if this action should be exposed to LLM as a callable tool.booleanChecks if redirects should be followed.booleanChecks if this action is marked as idempotent.booleanChecks if this is an LLM-based action.booleanChecks if MCP tool definitions should be cached.booleanChecks if MCP uses stdio transport.booleanChecks if this is an MCP tool action.booleanChecks if MCP parameters should be validated.booleanWhether to record variant usage statistics.booleanChecks if this is a WebService action.Returns a grouped view of all MCP tool configuration.booleanChecks if this action returns void.Creates a formatted string for prompt generation.Returns a grouped view of all web service configuration.
-
Constructor Details
-
ActionMetadata
Creates action metadata from a method. This is the main constructor used by ActionDiscovery.- Parameters:
method- the method to extract metadata fromparameters- list of parameter metadata
-
ActionMetadata
public ActionMetadata(String name, String description, ActionType type, List<ParamSpec> parameters, ActionHandler handler) Creates action metadata for a programmatically-defined action (TNS-551) — no reflectiveMethod; dispatch goes through the suppliedActionHandler. Every annotation-derived field takes the same default as a method without@ActionSpec(see the fallback branch of the reflective constructor), so downstream consumers treat it identically to a discovered action.- Parameters:
name- the action namedescription- human-readable descriptiontype- the action type (typicallyActionType.LOCAL)parameters- parameter metadata (may be empty)handler- the dispatch callback (non-null)
-
ActionMetadata
public ActionMetadata(String name, String description, ActionType type, List<ParamSpec> parameters, ActionHandler handler, ContractSpec contractSpec) AsActionMetadata(String, String, ActionType, List, ActionHandler)but with a declarativeContractSpec(TNS-637) — the programmatic equivalent of@Contractfor builder-added actions.- Parameters:
contractSpec- the@Contractgates;ContractSpec.NONEif none
-
ActionMetadata
public ActionMetadata(String name, String description, ActionType type, List<ParamSpec> parameters, ActionHandler handler, ContractSpec contractSpec, InputGuardrailConfig inputGuardrailConfig, OutputGuardrailConfig outputGuardrailConfig) AsActionMetadata(String, String, ActionType, List, ActionHandler, ContractSpec)but also carrying per-action programmatic guardrails (TNS-643) — the builder equivalent of method-level@InputGuardrail/@OutputGuardrail, for builder-added actions that have no method to read the annotation from.- Parameters:
contractSpec- the@Contractgates;ContractSpec.NONEif noneinputGuardrailConfig- per-action input guardrail, ornullfor noneoutputGuardrailConfig- per-action output guardrail, ornullfor none
-
-
Method Details
-
hasVariantOverride
public boolean hasVariantOverride()Checks if this action has a variant override.- Returns:
- true if action specifies a variant override
-
getVariantOverride
Gets the variant override for this action, if specified.- Returns:
- the variant override, or null if not specified
-
getVariantFallback
Gets the fallback variant for this action.- Returns:
- the fallback variant, or null if not specified
-
getVariantReason
Gets the reason for the variant override.- Returns:
- the reason string
-
isVariantRecordStats
public boolean isVariantRecordStats()Whether to record variant usage statistics.- Returns:
- true if stats should be recorded
-
isIdempotent
public boolean isIdempotent()Checks if this action is marked as idempotent. Idempotent actions can be safely retried without side effects.- Returns:
- true if action is idempotent
-
hasIdempotencyKey
public boolean hasIdempotencyKey()Checks if this action has an idempotency key defined.- Returns:
- true if idempotency key is specified
-
hasExamples
public boolean hasExamples()Checks if this action has usage examples defined.- Returns:
- true if examples are present
-
getExamples
Gets all usage examples (positive and negative) in declaration order.- Returns:
- list of all examples; empty if none declared
-
getPositiveExamples
Gets the positive (good) examples.- Returns:
- list of positive examples
-
getNegativeExamples
Gets the negative (bad) examples.- Returns:
- list of negative examples
-
hasLLMParameters
public boolean hasLLMParameters()Checks if this action has custom LLM parameters defined.- Returns:
- true if @LLMParam annotations are present
-
getParametersForLLM
Gets the parameters to expose to LLM. Returns custom LLM parameters if defined, otherwise returns method parameters.- Returns:
- parameters for LLM tool schema
-
getSimpleReturnTypeName
Gets the simple return type name (without package).- Returns:
- simple return type name
-
hasDescription
public boolean hasDescription()Checks if this action has a description.- Returns:
- true if description is not empty
-
hasParameters
public boolean hasParameters()Checks if this action has parameters.- Returns:
- true if parameters list is not empty
-
returnsVoid
public boolean returnsVoid()Checks if this action returns void.- Returns:
- true if return type is void
-
isWebService
public boolean isWebService()Checks if this is a WebService action.- Returns:
- true if type is WEB_SERVICE
-
isLLMAction
public boolean isLLMAction()Checks if this is an LLM-based action.- Returns:
- true if type is LLM
-
isDirectCode
public boolean isDirectCode()Checks if this is a direct code action.- Returns:
- true if type is LOCAL
-
isMcpTool
public boolean isMcpTool()Checks if this is an MCP tool action.- Returns:
- true if type is MCP_TOOL
-
getEndpoint
Gets the endpoint URL for WEB_SERVICE or MCP_TOOL actions.- Returns:
- endpoint URL or empty string if not configured
-
getMcpApiKeyEnv
Gets the MCP API key environment variable name.- Returns:
- environment variable name or empty string if not configured
-
isExposedToLLM
public boolean isExposedToLLM()Checks if this action should be exposed to LLM as a callable tool.Exposed action types:
- LOCAL — Direct method calls
- WEB_SERVICE — REST API calls
- LLM — LLM-driven actions (e.g., evaluation, strategy selection)
NOT exposed:
- MCP_TOOL — Exposed via separate MCP discovery mechanism
- Actions with excludeFromLLM=true
This method is used by ToolSchemaGenerator to determine which actions should be included in the LLM function calling schema.
- Returns:
- true if this action can be called by the LLM as a tool
-
isExcludedFromLLM
public boolean isExcludedFromLLM()Checks if this action is excluded from LLM tool list.Excluded actions can still be called programmatically but won't appear in the agent's system prompt or tool definitions.
- Returns:
- true if excluded from LLM
-
getEffects
Gets the effects defined for this action.Effects describe how the action modifies state fields, used by the Planner for simulation and by EffectApplier for automatic application.
- Returns:
- array of effects, never null
-
isAutoApplyEffects
public boolean isAutoApplyEffects()Checks if effects should be automatically applied after action execution.When true, the framework reads @Effect annotations and applies them to @State fields after the action method returns.
- Returns:
- true if effects should be auto-applied
-
toPromptString
Creates a formatted string for prompt generation. Format: "name(param1: Type1, param2: Type2): ReturnType - description"- Returns:
- formatted action string
-
getParameterCount
public int getParameterCount()Gets the parameter count.- Returns:
- number of parameters
-
getParameter
Gets a parameter by position.- Parameters:
position- parameter position (0-based)- Returns:
- parameter metadata
- Throws:
IndexOutOfBoundsException- if position is invalid
-
getMcpServerUrl
Gets the MCP server URL for MCP_TOOL actions.- Returns:
- MCP server URL or empty string
-
getMcpToolName
Gets the specific MCP tool name.- Returns:
- tool name or empty string (uses method name if empty)
-
getLlmSystemPrompt
Gets the per-action LLM system-prompt override.- Returns:
- system prompt or empty string when no override is set
-
hasLlmSystemPrompt
public boolean hasLlmSystemPrompt()Checks whether a per-action LLM system-prompt override is present.- Returns:
- true when
getLlmSystemPrompt()is non-empty
-
getLlmTemperature
public float getLlmTemperature()Gets the per-action LLM temperature override.- Returns:
- temperature when overridden, or
-1.0fwhen not
-
hasLlmTemperatureOverride
public boolean hasLlmTemperatureOverride()Checks whether a per-action LLM temperature override is present.- Returns:
- true when
getLlmTemperature()is >= 0
-
getContentType
Gets the content type for web service requests.- Returns:
- content type
-
getAccept
Gets the accept header value.- Returns:
- accept value
-
isFollowRedirects
public boolean isFollowRedirects()Checks if redirects should be followed.- Returns:
- true if follow redirects
-
getRetryCount
public int getRetryCount()Gets the retry count for web service.- Returns:
- retry count
-
getRetryBackoffMs
public int getRetryBackoffMs()Gets the retry backoff time in ms.- Returns:
- backoff in ms
-
getApiKeyHeader
Gets the API key header name for API_KEY auth.- Returns:
- header name
-
isMcpCacheToolDefinitions
public boolean isMcpCacheToolDefinitions()Checks if MCP tool definitions should be cached.- Returns:
- true if caching enabled
-
getMcpCacheTtlSeconds
public int getMcpCacheTtlSeconds()Gets the MCP cache TTL in seconds.- Returns:
- cache TTL
-
isMcpValidateParameters
public boolean isMcpValidateParameters()Checks if MCP parameters should be validated.- Returns:
- true if validation enabled
-
getMcpStdioCommand
Gets the MCP stdio command.- Returns:
- stdio command or empty
-
isMcpStdio
public boolean isMcpStdio()Checks if MCP uses stdio transport.- Returns:
- true if stdio command set
-
getMcpStdioArgs
Gets the MCP stdio arguments.- Returns:
- stdio args array
-
getMcpStdioEnv
Gets the MCP stdio environment variables.- Returns:
- env vars array
-
getMcpTimeout
public int getMcpTimeout()Gets the MCP request timeout.- Returns:
- timeout in ms
-
getMcpHeaders
Gets the MCP custom headers.- Returns:
- headers array
-
getMcpRetryCount
public int getMcpRetryCount()Gets the MCP retry count.- Returns:
- retry count
-
getMcpRetryBackoffMs
public int getMcpRetryBackoffMs()Gets the MCP retry backoff.- Returns:
- backoff in ms
-
webServiceConfig
Returns a grouped view of all web service configuration.Provides a cohesive object with HTTP endpoint, method, authentication, headers, and retry settings. Useful for executors that need multiple web service fields together.
- Returns:
- web service configuration record
-
mcpToolConfig
Returns a grouped view of all MCP tool configuration.Provides a cohesive object with MCP server URL, authentication, cache settings, retry, and stdio transport configuration.
- Returns:
- MCP tool configuration record
-
contractConfig
Returns a grouped view of all contract and planning configuration.Provides a cohesive object with preconditions, postconditions, goal fulfillment, and state effects.
- Returns:
- contract configuration record
-
hasPrecondition
public boolean hasPrecondition()Checks if this action has a precondition defined.- Returns:
- true if precondition is not empty
-
getPrecondition
Gets the precondition expression.- Returns:
- precondition string, never null
-
hasPostcondition
public boolean hasPostcondition()Checks if this action has a postcondition defined.- Returns:
- true if postcondition is not empty
-
getPostcondition
Gets the postcondition expression.- Returns:
- postcondition string, never null
-
getFulfills
Gets the goals that this action fulfills.- Returns:
- array of goal names, never null
-
hasFulfills
public boolean hasFulfills()Checks if this action fulfills any goals.- Returns:
- true if fulfills array is not empty
-
getMustNever
Gets the mustNever safety constraints for this action.- Returns:
- array of mustNever statements, never null
- Since:
- 0.9.0
-
hasMustNever
public boolean hasMustNever()Checks if this action has any mustNever constraints.- Returns:
- true if mustNever array is not empty
- Since:
- 0.9.0
-
getMustAlways
Gets the mustAlways liveness guarantees for this action.- Returns:
- array of mustAlways statements, never null
- Since:
- 0.9.0
-
hasMustAlways
public boolean hasMustAlways()Checks if this action has any mustAlways constraints.- Returns:
- true if mustAlways array is not empty
- Since:
- 0.9.0
-