subtask

inline suspend fun <Input, Output> AIAgentFunctionalContext.subtask(input: Input, tools: List<Tool<*, *>>? = null, llmModel: LLModel? = null, llmParams: LLMParams? = null, runMode: ToolCalls = ToolCalls.SEQUENTIAL, assistantResponseRepeatMax: Int? = null, defineTask: suspend AIAgentFunctionalContext.(input: Input) -> String): Output(source)

Executes a subtask within the larger context of an AI agent's functional operation. This method allows you to define a specific task to be performed, using the given input, tools, and optional configuration parameters.

Return

The result of the subtask execution, as an instance of type Output.

Parameters

Input

The type of input provided to the subtask.

Output

The type of the output expected from the subtask.

input

The input data required for the subtask execution.

tools

A list of tools available for use within the subtask.

llmModel

The optional large language model to be used during the subtask, if different from the default one.

llmParams

The configuration parameters for the large language model, such as temperature, etc.

runMode

The mode in which tools should be executed, either sequentially or in parallel.

assistantResponseRepeatMax

The maximum number of times the assistant response can repeat. Useful to control redundant outputs.

defineTask

A suspendable lambda defining the actual task logic, which takes the provided input and produces a task description.


inline suspend fun <Input, Output, OutputTransformed> AIAgentFunctionalContext.subtask(input: Input, tools: List<Tool<*, *>>? = null, finishTool: Tool<Output, OutputTransformed>, llmModel: LLModel? = null, llmParams: LLMParams? = null, runMode: ToolCalls = ToolCalls.SEQUENTIAL, assistantResponseRepeatMax: Int? = null, defineTask: suspend AIAgentFunctionalContext.(input: Input) -> String): OutputTransformed(source)

Executes a subtask within the AI agent's functional context. This method enables the use of tools to achieve a specific task based on the input provided. It defines the task using an inline function, employs tools iteratively, and attempts to complete the subtask with a designated finishing tool.

Return

The transformed final result of executing the finishing tool to complete the subtask.

Parameters

input

The input data required to define and execute the subtask.

tools

An optional list of tools that can be used to achieve the task, excluding the finishing tool.

finishTool

A mandatory tool that determines the final result of the subtask by producing and transforming output.

llmModel

An optional specific language learning model (LLM) to use for executing the subtask.

llmParams

Optional parameters for configuring the behavior of the LLM during subtask execution.

runMode

The mode in which tools should be executed, either sequentially or in parallel.

assistantResponseRepeatMax

The maximum number of feedback attempts allowed from the language model if the subtask is not completed.

defineTask

A suspendable function used to define the task based on the provided input.