Interface Agent.Effect.Builder
- Enclosing interface:
Agent.Effect<T>
-
Method Summary
Modifier and TypeMethodDescription<T> Agent.Effect<T> error(CommandException commandException) Create an error reply.<T> Agent.Effect<T> Create an error reply without calling the model.mcpTools(RemoteMcpTools tools, RemoteMcpTools... moreTools) Adds tools from one or more remote MCP servers.mcpTools(List<RemoteMcpTools> tools) Adds tools from one or more remote MCP servers.memory(MemoryProvider provider) model(ModelProvider provider) Define the AI model (LLM) to use.<T> Agent.Effect<T> reply(T message) Create a message reply without calling the model.<T> Agent.Effect<T> Create a message reply without calling the model.systemMessage(String message) Provides system-level instructions to the AI model that defines its behavior and context.systemMessageFromTemplate(String templateId) Create a system message from a template.systemMessageFromTemplate(String templateId, Object... args) Create a system message from a template.Adds one or more tool instances or classes that the AI model can use.Adds one or more tool instances or classes that the AI model can use.userMessage(String message) The user message to the AI model.
-
Method Details
-
model
Define the AI model (LLM) to use. If undefined, the model is defined by the default configuration inakka.javasdk.agent.model-provider -
systemMessage
Provides system-level instructions to the AI model that defines its behavior and context. The system message acts as a foundational prompt that establishes the AI's role, constraints, and operational parameters. It is processed before user messages and helps maintain consistent behavior throughout the interaction. -
tools
Adds one or more tool instances or classes that the AI model can use.Each argument can be either an object instance or a
Classobject. If aClassis provided, it will be instantiated at runtime using the configuredDependencyProvider.Workflows, Event Sourced Entities, Key Value Entities, and Views can also be used as tools. Unlike regular objects, component instances cannot be passed to this method. Instead, you must pass the component
Classobject.Each instance or class must have at least one public method annotated with
FunctionTool. If no such method is found, anIllegalArgumentExceptionwill be thrown. These methods will be available as tools for the AI model to invoke.When using components as tools, special rules apply to which methods can be annotated with
FunctionTool. SeeFunctionToolfor details.- Returns:
- this builder for method chaining
-
tools
Adds one or more tool instances or classes that the AI model can use.Each element in the list can be either an object instance or a
Classobject. If aClassis provided, it will be instantiated at runtime using the configuredDependencyProvider.Workflows, Event Sourced Entities, Key Value Entities, and Views can also be used as tools. Unlike regular objects, component instances cannot be passed to this method. Instead, you must pass the component
Classobject.Each instance or class must have at least one public method annotated with
FunctionTool. If no such method is found, anIllegalArgumentExceptionwill be thrown. These methods will be available as tools for the AI model to invoke.When using components as tools, special rules apply to which methods can be annotated with
FunctionTool. SeeFunctionToolfor details.- Parameters:
toolInstancesOrClasses- one or more objects or classes exposing tool methods- Returns:
- this builder for method chaining
-
systemMessageFromTemplate
Create a system message from a template. Call @PromptTemplatebefore to initiate or update template value.Provides system-level instructions to the AI model that defines its behavior and context. The system message acts as a foundational prompt that establishes the AI's role, constraints, and operational parameters. It is processed before user messages and helps maintain consistent behavior throughout the interaction.
- Parameters:
templateId- the id of the template to use
-
systemMessageFromTemplate
Create a system message from a template. Call @PromptTemplatebefore to initiate or update template value. Provide arguments that will be applied to the template using JavaString.formatted(java.lang.Object...)method.Provides system-level instructions to the AI model that defines its behavior and context. The system message acts as a foundational prompt that establishes the AI's role, constraints, and operational parameters. It is processed before user messages and helps maintain consistent behavior throughout the interaction.
- Parameters:
templateId- the id of the template to useargs- the arguments to apply to the template
-
memory
-
mcpTools
Adds tools from one or more remote MCP servers.Construct instances using
RemoteMcpTools.fromServer(String) -
mcpTools
Adds tools from one or more remote MCP servers.Construct instances using
RemoteMcpTools.fromServer(String) -
userMessage
The user message to the AI model. This message represents the specific query, instruction, or input that will be processed by the model to generate a response. -
reply
Create a message reply without calling the model.- Type Parameters:
T- The type of the message that must be returned by this call.- Parameters:
message- The payload of the reply.- Returns:
- A message reply.
-
reply
Create a message reply without calling the model.- Type Parameters:
T- The type of the message that must be returned by this call.- Parameters:
message- The payload of the reply.metadata- The metadata for the message.- Returns:
- A message reply.
-
error
Create an error reply without calling the model. A short version of {effects().error(new CommandException(message))}.- Type Parameters:
T- The type of the message that must be returned by this call.- Parameters:
message- The error message.- Returns:
- An error reply.
-
error
Create an error reply.CommandExceptionwill be serialized and sent to the client. It's possible to catch it with try-catch statement orCompletionStageAPI when using asyncComponentClientAPI.- Type Parameters:
T- The type of the message that must be returned by this call.- Parameters:
commandException- The command exception to be returned.- Returns:
- An error reply.
-