Interface IAgenticaExecutor<Model>

Executor of the Agentic AI.

IAgenticaExecutor represents an executor of the Agentica, composing its internal agents to accomplish the Agentic AI through the LLM (Large Language Model) function calling.

You can customize one of these internal agents by configuring properties of the IAgenticaExecutor type, and assigning it to the IAgenticaConfig.executor property. If you set the initialize as null value, the Agentica will skip the initialize process and directly go to the select process.

By the way, when customizing the executor member, it would better to reference the guide documents of @agentica/core, and internal agents' implementation code. It's because if you take some mistake on the executor logic, it can entirely break the Agentica's operation.

interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
    call: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
    cancel: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
    describe: (
        ctx: AgenticaContext<Model>,
        executes: AgenticaExecutePrompt<Model, any>[],
    ) => Promise<AgenticaPrompt<Model>[]>;
    initialize:
        | null
        | (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
    select: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
}

Type Parameters

  • Model extends ILlmSchema.Model

Properties

call: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>

Function caller agent.

Call agent performs the LLM (Large Language Model) function calling from the candidate functions enrolled in the AgenticaContext.stack. And the scope of function calling is, not only just arguments filling, but also actual executing the function and returning the result.

By the way, conversation context with user can be not enough to filling the arguments of the candidate functions. In that case, the call agent will ask the user to fill the missing arguments.

Otherwise the cpnversation context is enough, so that succeeded to call some candidate functions, the call agent will step to the describe agent to explain the result of the function calling to the user as markdown content.

Type declaration

Recommend not to customize, due to its validation feedback strategy is working very well, and the call agent is the most general topic which can be universally applied to all domain fields.

cancel: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>

Function canceler agent.

Cancel agent erases the candidate functions from the AgenticaContext.stack by analyzing the conversation context with the user.

For reference, the first reason of the cancelation is explicit order from user to the previous requested function. For example, user had requested to send an email to the agent, but suddenly user says to cancel the email sending.

The seconod reason n of the cancelation is the multiple candidate functions had been selected at once by the select agent due to lack of conversation context or homogeneity between the heterogeneous functions. And in the multiple candidate functions, one thing is clearly determined by the call agent, so that drop the other candidate functions.

Type declaration

describe: (
    ctx: AgenticaContext<Model>,
    executes: AgenticaExecutePrompt<Model, any>[],
) => Promise<AgenticaPrompt<Model>[]>

Describer agent of the function calling result.

Describe agent explains the results of the function callings to the user as markdown content.

Type declaration

initialize:
    | null
    | (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>

Initializer agent listing up functions.

initialize agent is the first agent that Agentica would meet which judges whether the user's conversation implies to call some function or not.

And if the initialize agent judges the user's conversation implies to call some function, the initialize agent will call the AgenticaContext.initialize function, and inform every functions enrolled in the IAgenticaController to the AI agent. And then, the initialize agent will not never be called again, and let Agentica to go to the next select agent.

Otherwise the user's conversation does not imply the request of function calling, it would just work like plain chatbot, and just conversate with the user.

By the way, if you wanna skip the initialize agent, you can do it by configuring the IAgenticaConfig.executor as null value. In that case, the initialize agent will never be called, and Agentica just starts from the select agent.

Context of the agent

List of prompts generated by the initializer

select: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>

Function selector agent.

Select agent finds candidate functions to call from the conversation context with the user. And the candidate functions would be enrolled to the AgenticaContext.stack, and the next call agent will perform the LLM (Large Language Model) function calling.

Note that, the select agent does not perform the LLM function calling. It ends with just finding the candidate functions to call.

By the way, if the select agent can't specify a certain function to call due to lack of conversation context or homogeneity between heterogeneous functions, how select agent works? In that case, select agent it will just enroll every candidate functions to the stack, and let the next call agent to determine the proper function to call. And then let cancel agent to erase the other candidate functions from the stack.

Additionally, if select agent could not find any candidate function from the conversation context with user, it would just act like plain chatbot conversating with the user.

Type declaration