Package akka.javasdk.testkit
Class TestModelProvider.AutonomousAgentTools
Object
akka.javasdk.testkit.TestModelProvider.AutonomousAgentTools
- Enclosing class:
TestModelProvider
Factory methods for
TestModelProvider.ToolInvocationRequest instances that correspond to the internal
tools exposed by the autonomous agent runtime to the LLM.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordParticipant reference for scripted conversations, with type and reference name.static final recordA step in a scripted conversation, specifying speaker and guidance.static final recordSpecifies a team member type and count for acreate_teamtool invocation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTool name for broadcasting a message to a conversation.static final StringTool name for cancelling unclaimed tasks from backlog (lead side).static final StringTool name for claiming a task (member side).static final StringTool name for completing a task.static final StringTool name for creating a team.static final StringTool name for directing a participant in a conversation (directed mode).static final StringTool name for disbanding a team.static final StringTool name for ending a moderated conversation (directed mode).static final StringTool name for failing a task.static final StringTool name for getting backlog status (member side).static final StringTool name for getting managed backlog status (lead side).static final StringTool name for looking up a task by ID.static final StringTool name for getting team status.static final StringTool name for providing a prompt during a scripted conversation step.static final StringTool name for releasing a task (member side).static final StringTool name for sending a message to another agent.static final StringTool name for starting a moderated conversation.static final StringTool name for submitting a turn response.static final StringTool name for transferring a task (member side). -
Method Summary
Modifier and TypeMethodDescriptionCreates aTestModelProvider.ToolInvocationRequestfor thebroadcasttool.Creates aTestModelProvider.ToolInvocationRequestfor thecancel_unclaimed_tasks_from_backlogtool.cancelUnclaimedTasksFromBacklog(String backlogId) Creates aTestModelProvider.ToolInvocationRequestfor thecancel_unclaimed_tasks_from_backlogtool with a specific backlog ID.Creates aTestModelProvider.ToolInvocationRequestfor theclaim_tasktool.Creates aTestModelProvider.ToolInvocationRequestfor theclaim_tasktool with a specific backlog ID.completeTask(Object result) Creates aTestModelProvider.ToolInvocationRequestfor thecomplete_tasktool, serializing the given result object to JSON.completeTaskJson(String resultJson) Creates aTestModelProvider.ToolInvocationRequestfor thecomplete_tasktool, with the given raw result JSON string.createTaskForBacklog(akka.javasdk.agent.task.Task<?> task, String instructions) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool.createTaskForBacklog(akka.javasdk.agent.task.Task<?> task, String backlogId, String instructions) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool with a specific backlog ID.createTaskForBacklog(akka.javasdk.agent.task.TaskTemplate<?> task, String backlogId, Map<String, String> templateParams) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool with a specific backlog ID, filling template parameters for aTaskTemplate.createTaskForBacklog(akka.javasdk.agent.task.TaskTemplate<?> task, Map<String, String> templateParams) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool, filling template parameters for aTaskTemplate.static StringcreateTaskForBacklogToolName(akka.javasdk.agent.task.TaskDefinition<?> task) Returns the tool name for acreate_<taskType>_task_for_backlogtool, derived from the task definition name.Creates aTestModelProvider.ToolInvocationRequestfor thecreate_teamtool.delegateTo(akka.javasdk.agent.task.Task<?> task, Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass, String instructions) Creates aTestModelProvider.ToolInvocationRequestfor adelegate_<task>_to_<agent>tool, deriving the tool name from the task definition and the target agent's component ID.delegateTo(akka.javasdk.agent.task.TaskTemplate<?> task, Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass, Map<String, String> templateParams) Creates aTestModelProvider.ToolInvocationRequestfor adelegate_<task>_to_<agent>tool, filling template parameters for aTaskTemplate.delegateTo(Class<? extends akka.javasdk.agent.Agent> agentClass, String argsJson) Creates aTestModelProvider.ToolInvocationRequestfor adelegate_to_<agent>tool, used when an autonomous agent delegates to a request-based agent.static StringdelegateToToolName(akka.javasdk.agent.task.TaskDefinition<?> task, Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass) Returns the tool name for adelegate_<task>_to_<agent>tool, derived from the task definition and target agent's component ID.static StringdelegateToToolName(Class<? extends akka.javasdk.agent.Agent> agentClass) Returns the tool name for adelegate_to_<agent>tool for request-based agent delegation, derived from the target agent's component ID.Creates aTestModelProvider.ToolInvocationRequestfor thedirecttool (directed mode only).Creates aTestModelProvider.ToolInvocationRequestfor thedisband_teamtool.disbandTeam(String teamId) Creates aTestModelProvider.ToolInvocationRequestfor thedisband_teamtool with a specific team ID.Creates aTestModelProvider.ToolInvocationRequestfor theend_conversationtool (directed mode only).Extracts messaging contact addresses from input messages.Creates aTestModelProvider.ToolInvocationRequestfor thefail_tasktool.Creates aTestModelProvider.ToolInvocationRequestfor theget_backlog_statustool.getBacklogStatus(String backlogId) Creates aTestModelProvider.ToolInvocationRequestfor theget_backlog_statustool with a specific backlog ID.Creates aTestModelProvider.ToolInvocationRequestfor theget_managed_backlog_statustool.getManagedBacklogStatus(String backlogId) Creates aTestModelProvider.ToolInvocationRequestfor theget_managed_backlog_statustool with a specific backlog ID.Creates aTestModelProvider.ToolInvocationRequestfor theget_tasktool.Creates aTestModelProvider.ToolInvocationRequestfor theget_team_statustool.getTeamStatus(String teamId) Creates aTestModelProvider.ToolInvocationRequestfor theget_team_statustool with a specific team ID.handoffTo(Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass, String context) Creates aTestModelProvider.ToolInvocationRequestfor ahandoff_to_<agent>tool, deriving the tool name from the target agent's component ID.static StringhandoffToToolName(Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass) Returns the tool name for ahandoff_to_<agent>tool, derived from the target agent's component ID.providePrompt(String prompt) Creates aTestModelProvider.ToolInvocationRequestfor theprovide_prompttool (scripted mode).releaseTask(String taskId) Creates aTestModelProvider.ToolInvocationRequestfor therelease_tasktool.releaseTask(String backlogId, String taskId) Creates aTestModelProvider.ToolInvocationRequestfor therelease_tasktool with a specific backlog ID.sendMessage(String to, String message) Creates aTestModelProvider.ToolInvocationRequestfor thesend_messagetool.startDirectedConversation(String topic, int maxRounds, List<TestModelProvider.AutonomousAgentTools.ParticipantRef> participants) Creates aTestModelProvider.ToolInvocationRequestfor thestart_conversationtool with a directed pattern.startScriptedConversation(String topic, List<TestModelProvider.AutonomousAgentTools.ParticipantRef> participants, List<TestModelProvider.AutonomousAgentTools.ScriptStep> script) Creates aTestModelProvider.ToolInvocationRequestfor thestart_conversationtool with a scripted pattern.submitTurn(String response) Creates aTestModelProvider.ToolInvocationRequestfor thesubmit_turntool.transferTask(String taskId, String agentId) Creates aTestModelProvider.ToolInvocationRequestfor thetransfer_tasktool.transferTask(String backlogId, String taskId, String agentId) Creates aTestModelProvider.ToolInvocationRequestfor thetransfer_tasktool with a specific backlog ID.
-
Field Details
-
COMPLETE_TASK
Tool name for completing a task.- See Also:
-
FAIL_TASK
Tool name for failing a task.- See Also:
-
GET_TASK
Tool name for looking up a task by ID.- See Also:
-
CREATE_TEAM
Tool name for creating a team.- See Also:
-
GET_TEAM_STATUS
Tool name for getting team status.- See Also:
-
DISBAND_TEAM
Tool name for disbanding a team.- See Also:
-
GET_MANAGED_BACKLOG_STATUS
Tool name for getting managed backlog status (lead side).- See Also:
-
CANCEL_UNCLAIMED_TASKS_FROM_BACKLOG
Tool name for cancelling unclaimed tasks from backlog (lead side).- See Also:
-
GET_BACKLOG_STATUS
Tool name for getting backlog status (member side).- See Also:
-
CLAIM_TASK
Tool name for claiming a task (member side).- See Also:
-
RELEASE_TASK
Tool name for releasing a task (member side).- See Also:
-
TRANSFER_TASK
Tool name for transferring a task (member side).- See Also:
-
SEND_MESSAGE
Tool name for sending a message to another agent.- See Also:
-
START_CONVERSATION
Tool name for starting a moderated conversation.- See Also:
-
PROVIDE_PROMPT
Tool name for providing a prompt during a scripted conversation step.- See Also:
-
DIRECT
Tool name for directing a participant in a conversation (directed mode).- See Also:
-
BROADCAST
Tool name for broadcasting a message to a conversation.- See Also:
-
END_CONVERSATION
Tool name for ending a moderated conversation (directed mode).- See Also:
-
SUBMIT_TURN
Tool name for submitting a turn response. Used by participants when they have the floor, and by the moderator for their own turns in scripted conversations.- See Also:
-
-
Method Details
-
completeTaskJson
Creates aTestModelProvider.ToolInvocationRequestfor thecomplete_tasktool, with the given raw result JSON string. The JSON must conform to the task's result type schema. UsecompleteTask(Object)for type-safe serialization of result objects. -
completeTask
Creates aTestModelProvider.ToolInvocationRequestfor thecomplete_tasktool, serializing the given result object to JSON. For non-object result types (String, Integer, Number, Boolean, and collections/arrays), wraps the value in a{"result": ...}JSON object matching the runtime's expected format. For object types (records, POJOs), the object's own properties become the tool arguments directly (passthrough). -
failTask
Creates aTestModelProvider.ToolInvocationRequestfor thefail_tasktool.- Parameters:
reason- the failure reason
-
getTask
Creates aTestModelProvider.ToolInvocationRequestfor theget_tasktool.- Parameters:
taskId- the ID of the task to look up
-
handoffToToolName
public static String handoffToToolName(Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass) Returns the tool name for ahandoff_to_<agent>tool, derived from the target agent's component ID. -
handoffTo
public static TestModelProvider.ToolInvocationRequest handoffTo(Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass, String context) Creates aTestModelProvider.ToolInvocationRequestfor ahandoff_to_<agent>tool, deriving the tool name from the target agent's component ID.- Parameters:
agentClass- the autonomous agent class to hand off to (must carry@Componentor@Component)context- context passed to the receiving agent
-
delegateToToolName
public static String delegateToToolName(akka.javasdk.agent.task.TaskDefinition<?> task, Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass) Returns the tool name for adelegate_<task>_to_<agent>tool, derived from the task definition and target agent's component ID. -
delegateTo
public static TestModelProvider.ToolInvocationRequest delegateTo(akka.javasdk.agent.task.Task<?> task, Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass, String instructions) Creates aTestModelProvider.ToolInvocationRequestfor adelegate_<task>_to_<agent>tool, deriving the tool name from the task definition and the target agent's component ID.- Parameters:
task- the task being delegatedagentClass- the agent class to delegate to (must carry@Componentor@Component)instructions- instructions passed to the delegated agent
-
delegateTo
public static TestModelProvider.ToolInvocationRequest delegateTo(akka.javasdk.agent.task.TaskTemplate<?> task, Class<? extends akka.javasdk.agent.autonomous.AutonomousAgent> agentClass, Map<String, String> templateParams) Creates aTestModelProvider.ToolInvocationRequestfor adelegate_<task>_to_<agent>tool, filling template parameters for aTaskTemplate.- Parameters:
task- the task template being delegatedagentClass- the agent class to delegate to (must carry@Componentor@Component)templateParams- values for the template parameters
-
delegateToToolName
Returns the tool name for adelegate_to_<agent>tool for request-based agent delegation, derived from the target agent's component ID. -
delegateTo
public static TestModelProvider.ToolInvocationRequest delegateTo(Class<? extends akka.javasdk.agent.Agent> agentClass, String argsJson) Creates aTestModelProvider.ToolInvocationRequestfor adelegate_to_<agent>tool, used when an autonomous agent delegates to a request-based agent. The runtime resolves the target method from the agent's definition (request-based agents have a single effect method).- Parameters:
agentClass- the request-based agent class (must carry@Componentor@Component)argsJson- the JSON arguments to pass (must match the method's parameter type)
-
createTeam
public static TestModelProvider.ToolInvocationRequest createTeam(TestModelProvider.AutonomousAgentTools.TeamMemberSpec... members) Creates aTestModelProvider.ToolInvocationRequestfor thecreate_teamtool.- Parameters:
members- the team member specifications (type derived from component ID, with count)
-
getTeamStatus
Creates aTestModelProvider.ToolInvocationRequestfor theget_team_statustool. Theteam_idis optional when there is only one active team. -
getTeamStatus
Creates aTestModelProvider.ToolInvocationRequestfor theget_team_statustool with a specific team ID. Required when multiple teams are active. -
disbandTeam
Creates aTestModelProvider.ToolInvocationRequestfor thedisband_teamtool. Theteam_idis optional when there is only one active team. -
disbandTeam
Creates aTestModelProvider.ToolInvocationRequestfor thedisband_teamtool with a specific team ID. Required when multiple teams are active. -
createTaskForBacklogToolName
Returns the tool name for acreate_<taskType>_task_for_backlogtool, derived from the task definition name. -
createTaskForBacklog
public static TestModelProvider.ToolInvocationRequest createTaskForBacklog(akka.javasdk.agent.task.Task<?> task, String instructions) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool. Thebacklog_idis auto-resolved when there is only one backlog.For
TaskTemplatedefinitions, use the overload that accepts aMapof template parameter values instead.- Parameters:
task- the task definition to createinstructions- instructions for the task
-
createTaskForBacklog
public static TestModelProvider.ToolInvocationRequest createTaskForBacklog(akka.javasdk.agent.task.TaskTemplate<?> task, Map<String, String> templateParams) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool, filling template parameters for aTaskTemplate. Thebacklog_idis auto-resolved when there is only one backlog.- Parameters:
task- the task template to createtemplateParams- values for the template parameters (e.g. "feature", "requirements")
-
createTaskForBacklog
public static TestModelProvider.ToolInvocationRequest createTaskForBacklog(akka.javasdk.agent.task.Task<?> task, String backlogId, String instructions) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool with a specific backlog ID. Required when multiple backlogs exist.- Parameters:
task- the task definition to createbacklogId- the backlog IDinstructions- instructions for the task
-
createTaskForBacklog
public static TestModelProvider.ToolInvocationRequest createTaskForBacklog(akka.javasdk.agent.task.TaskTemplate<?> task, String backlogId, Map<String, String> templateParams) Creates aTestModelProvider.ToolInvocationRequestfor acreate_<taskType>_task_for_backlogtool with a specific backlog ID, filling template parameters for aTaskTemplate.- Parameters:
task- the task template to createbacklogId- the backlog IDtemplateParams- values for the template parameters
-
getManagedBacklogStatus
Creates aTestModelProvider.ToolInvocationRequestfor theget_managed_backlog_statustool. Thebacklog_idis auto-resolved when there is only one backlog. -
getManagedBacklogStatus
Creates aTestModelProvider.ToolInvocationRequestfor theget_managed_backlog_statustool with a specific backlog ID. Required when multiple backlogs exist. -
cancelUnclaimedTasksFromBacklog
Creates aTestModelProvider.ToolInvocationRequestfor thecancel_unclaimed_tasks_from_backlogtool. Thebacklog_idis auto-resolved when there is only one backlog. -
cancelUnclaimedTasksFromBacklog
public static TestModelProvider.ToolInvocationRequest cancelUnclaimedTasksFromBacklog(String backlogId) Creates aTestModelProvider.ToolInvocationRequestfor thecancel_unclaimed_tasks_from_backlogtool with a specific backlog ID. Required when multiple backlogs exist. -
getBacklogStatus
Creates aTestModelProvider.ToolInvocationRequestfor theget_backlog_statustool. Thebacklog_idis auto-resolved when there is only one backlog. -
getBacklogStatus
Creates aTestModelProvider.ToolInvocationRequestfor theget_backlog_statustool with a specific backlog ID. Required when multiple backlogs exist. -
claimTask
Creates aTestModelProvider.ToolInvocationRequestfor theclaim_tasktool.- Parameters:
taskId- the ID of the task to claim
-
claimTask
Creates aTestModelProvider.ToolInvocationRequestfor theclaim_tasktool with a specific backlog ID. Required when multiple backlogs exist.- Parameters:
backlogId- the backlog IDtaskId- the ID of the task to claim
-
releaseTask
Creates aTestModelProvider.ToolInvocationRequestfor therelease_tasktool.- Parameters:
taskId- the ID of the task to release
-
releaseTask
Creates aTestModelProvider.ToolInvocationRequestfor therelease_tasktool with a specific backlog ID. Required when multiple backlogs exist.- Parameters:
backlogId- the backlog IDtaskId- the ID of the task to release
-
transferTask
Creates aTestModelProvider.ToolInvocationRequestfor thetransfer_tasktool.- Parameters:
taskId- the ID of the task to transferagentId- the ID of the agent to transfer the task to
-
transferTask
public static TestModelProvider.ToolInvocationRequest transferTask(String backlogId, String taskId, String agentId) Creates aTestModelProvider.ToolInvocationRequestfor thetransfer_tasktool with a specific backlog ID. Required when multiple backlogs exist.- Parameters:
backlogId- the backlog IDtaskId- the ID of the task to transferagentId- the ID of the agent to transfer the task to
-
sendMessage
Creates aTestModelProvider.ToolInvocationRequestfor thesend_messagetool. Thetoaddress can be obtained from the runtime-injected messaging contacts usingextractContacts(InputMessage).- Parameters:
to- the agent address from the contacts list (e.g."developer/team-id-developer-1")message- the message to send
-
extractContacts
Extracts messaging contact addresses from input messages. The runtime injects contacts in user messages with the format"Messaging contacts: agent-type/instance-id, ...". This utility parses those messages and returns the contact addresses.Usage example in a test:
leadModel.fixedResponse(msg -> { if (msg instanceof TestModelProvider.UserMessage um) { var contacts = extractContacts(um); if (!contacts.isEmpty()) { return new AiResponse(sendMessage(contacts.get(0), "Hello!")); } } return new AiResponse("Acknowledged."); });- Parameters:
message- the input message to extract contacts from- Returns:
- list of contact addresses, empty if no contacts found
-
startScriptedConversation
public static TestModelProvider.ToolInvocationRequest startScriptedConversation(String topic, List<TestModelProvider.AutonomousAgentTools.ParticipantRef> participants, List<TestModelProvider.AutonomousAgentTools.ScriptStep> script) Creates aTestModelProvider.ToolInvocationRequestfor thestart_conversationtool with a scripted pattern. The moderator defines participants and a turn script upfront.- Parameters:
topic- the conversation topicparticipants- the participant references (type and reference name)script- the ordered turn sequence
-
startDirectedConversation
public static TestModelProvider.ToolInvocationRequest startDirectedConversation(String topic, int maxRounds, List<TestModelProvider.AutonomousAgentTools.ParticipantRef> participants) Creates aTestModelProvider.ToolInvocationRequestfor thestart_conversationtool with a directed pattern. The moderator controls each turn dynamically.- Parameters:
topic- the conversation topicmaxRounds- safety limit on conversation roundsparticipants- the participant references (type and reference name)
-
providePrompt
Creates aTestModelProvider.ToolInvocationRequestfor theprovide_prompttool (scripted mode). Provides a contextual prompt for the current participant step.- Parameters:
prompt- the prompt to give to the participant
-
direct
Creates aTestModelProvider.ToolInvocationRequestfor thedirecttool (directed mode only). Grants the floor to a named participant with a direction message.- Parameters:
participantRef- the reference name of the participant to directmessage- the direction message for the participant
-
broadcast
Creates aTestModelProvider.ToolInvocationRequestfor thebroadcasttool. Posts a message to the conversation without granting the floor.- Parameters:
message- the message to broadcast
-
endConversation
Creates aTestModelProvider.ToolInvocationRequestfor theend_conversationtool (directed mode only). Ends the conversation and receives the full transcript. -
submitTurn
Creates aTestModelProvider.ToolInvocationRequestfor thesubmit_turntool. Used by participants to submit their response, and by the moderator for their own turns in scripted conversations.- Parameters:
response- the response message
-