The built in tool definition
Adds a Javascript function as a tool using callable
Function will be called when the tool invocation occured
Tool descriotion
Adds a REST API tool that performs external HTTP requests
REST API tool definition
Optional
auth: ToolAuthenticatorOptional authenticator to inject into the request
Register a MCP client and add its tools to agent.
The unique name of the MCP client. If there's already a MCP client with the same name, it throws Error.
MCP client transport to use for client connection
Optional
options: MCPClientStartOptions & { toolsToAdd?: string[] }Optional
toolsToAdd?: string[]Optional list of tool names to add. If not specified, all tools are added.
Loads tools from a predefined JSON preset file
Name of the tool preset
Optional
args: { authenticator?: ToolAuthenticator }Optional
authenticator?: ToolAuthenticatorOptional authenticator to inject into the request
Clear the history of conversation messages.
Clear the registered tools.
Defines the LLM components to the runtime. This must be called before using any other method in the class. If already defined, this is a no-op.
The runtime environment associated with the agent
The LLM model to use in this agent
Optional
args: { systemMessage?: string }Optional
systemMessage?: stringOptional system message to set the initial assistant context
Delete resources in the agent. If the agent is not in an initialized state, this is a no-op.
Get the current conversation history. Each item in the list represents a message from either the user or the assistant.
Get the list of registered tools.
Optional
options: { reasoning?: boolean }Removes the MCP client and its tools from the agent.
The unique name of the MCP client. If there's no MCP client matches the name, it throws Error.
The
Agent
class provides a high-level interface for interacting with large language models (LLMs) in Ailoy. It abstracts the underlying runtime and VM logic, allowing users to easily send queries and receive streaming responses. Agents can be extended with external tools or APIs to provide real-time or domain-specific knowledge, enabling more powerful and context-aware interactions.