Package akka.javasdk.annotations
Annotation Interface FunctionTool
Annotation to expose methods as function tools that can be invoked by AI agents.
Methods annotated with @FunctionTool become available as tools that the AI model can
choose to invoke based on the task requirements. The LLM determines which tools to call and with
which parameters based on the tool descriptions and the user's request.
Tool Discovery: Function tools can be defined in three ways:
- Agent-defined: Methods within the agent class itself (can be private)
- External tools: Methods in separate classes registered via
effects().tools() - Components as tools: Methods in Workflows, Event Sourced Entities, Key
Value Entities, and Views classes registered via
effects().tools()
Components as tools rules:
- Only Workflows, Event Sourced Entities, Key Value Entities, and Views can be used as tools
- For Workflows, only public methods returning
Workflow.EffectorWorkflow.ReadOnlyEffectcan be annotated with FunctionTool. Methods returningWorkflow.StepEffectare not allowed. - For Event Sourced Entities, only public methods returning
EventSourcedEntity.EffectorEventSourcedEntity.ReadOnlyEffectcan be annotated with FunctionTool. - For Key Value Entities, only public methods returning
KeyValueEntity.EffectorKeyValueEntity.ReadOnlyEffectcan be annotated with FunctionTool. - For Views, only public methods returning
View.QueryEffectcan be annotated with FunctionTool. Methods returningView.QueryStreamEffectare not allowed.
Best Practices:
- Provide clear, descriptive tool descriptions
- Use
Descriptionannotations on parameters to help the LLM understand usage - Use
Optionalparameters for non-required arguments - Keep tool functions focused on a single, well-defined task
Tool Execution: The agent automatically handles the tool execution loop: the LLM requests tool calls, the agent executes them, incorporates results into the session context, and continues until the LLM no longer needs to invoke tools.
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional Elements