Whatever message this page gives is out now! Go check it out!
TOOLS array. Each entry points to a CFC and optionally specifies which methods to expose.toolExecutionRequests array. Each entry describes the tool the model wants to call and the arguments it wants to pass. Your code is responsible for executing the tool and handling the result.DESCRIPTION for each exposed method. Without one, the AI may not invoke the tool even when the user's query clearly matches. Good descriptions tell the model when to use the tool, not just what it does.METHODS array to expose every public method in the CFC. ColdFusion derives tool names and parameter schemas automatically from the method signatures.
agent = Agent({
CHATMODEL : chatModel,
TOOLS : [
{ CFC : "tools.SupportTool" } // all public methods exposed
]
});
METHODS array to expose only named methods. Each entry requires a METHOD name and a DESCRIPTION that tells the model when and why to use it.
agent = Agent({
CHATMODEL : chatModel,
TOOLS : [
{
CFC : "tools.SupportTool",
METHODS : [
{
METHOD : "getTicketStatus",
DESCRIPTION : "Get the status of a support ticket by ID. Use this when the user asks about the progress or state of a ticket, e.g., 'What is the status of ticket TKT-12345?'"
},
{
METHOD : "createTicket",
DESCRIPTION : "Create a new support ticket. Use this when the user wants to report an issue or request support."
}
]
}
]
});
TOOLS : [
{ CFC : "tools.WeatherTool" }, // all methods
{ CFC : "tools.SupportTool", METHODS : [...] } // specific methods only
]
agent.chat() returns a struct with a toolExecutionRequests array instead of (or in addition to) a plain message. Each entry in the array describes the tool call the model wants to make:| Field | Type | Description |
|---|---|---|
name | String | The name of the CFC method to invoke |
arguments | Struct | The arguments the model wants to pass to the method |
toolExecutionRequests, executing the tool, and handling the result.
response = agent.chat("What is the status of ticket TKT-12345?", "user1");
if (structKeyExists(response, "toolExecutionRequests")
&& arrayLen(response.toolExecutionRequests) > 0) {
toolRequest = response.toolExecutionRequests[1];
writeOutput("Tool requested: " & toolRequest.name);
writeOutput("Arguments: " & serializeJSON(toolRequest.arguments));
// Execute the tool and handle the result in your application
}
component output=false {
remote string function getTicketStatus(required string ticketId) {
hint="Returns the current status of a support ticket by its ID.";
if (arguments.ticketId == "TKT-12345") {
return "in progress";
}
return "closed";
}
remote struct function createTicket(
required string summary,
required string priority
) {
hint="Creates a new support ticket with the given summary and priority.";
return {
id : createUUID(),
summary : arguments.summary,
priority : arguments.priority,
status : "new"
};
}
}
<cfscript>
chatModel = ChatModel({
PROVIDER : "openAi",
APIKEY : "#application.apiKey#",
MODELNAME : "gpt-4o-mini"
});
agent = Agent({
CHATMODEL : chatModel,
CHATMEMORY : { MAXMESSAGES : 20, PERUSER : true },
TOOLS : [
{
CFC : "tools.SupportTool",
METHODS : [
{
METHOD : "getTicketStatus",
DESCRIPTION : "Get the status of a support ticket by ID. Use this when the user asks about the progress or state of a ticket."
},
{
METHOD : "createTicket",
DESCRIPTION : "Create a new support ticket from user input. Use this when the user wants to report an issue or request support."
}
]
}
]
});
response = agent.chat("My ticket ID is TKT-12345. What is its status?", "user1");
if (structKeyExists(response, "toolExecutionRequests")
&& arrayLen(response.toolExecutionRequests) > 0) {
toolReq = response.toolExecutionRequests[1];
writeOutput("Tool: " & toolReq.name & " | Args: " & serializeJSON(toolReq.arguments));
} else {
writeOutput(response.message);
}
</cfscript>
<cfscript>
chatModel = ChatModel({
PROVIDER : "openAi",
APIKEY : "#application.apiKey#",
MODELNAME : "gpt-4o-mini"
});
agent = Agent({
CHATMODEL : chatModel,
TOOLS : [{ CFC : "tools.SupportTool" }] // all public methods exposed
});
response = agent.chat("Create a ticket for a login issue with high priority.", "user1");
if (structKeyExists(response, "toolExecutionRequests")
&& arrayLen(response.toolExecutionRequests) > 0) {
toolReq = response.toolExecutionRequests[1];
writeOutput("Tool: " & toolReq.name & " | Args: " & serializeJSON(toolReq.arguments));
} else {
writeOutput(response.message);
}
</cfscript>
METHODS array) in production to limit what the AI can invoke. Reserve the all-methods approach for development or when all CFC methods are intentionally part of the agent's capabilities.