llm.createToolResult(options)

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Creates a tool result that you can provide when calling llm.generateText(options) or llm.generateTextStreamed(options).

Tool results let you send the output of a tool (such as the result of a SuiteQL query or a business operation) back to the large language model (LLM). You generate tool results in your SuiteScript code after handling a tool call request, which is represented by a llm.ToolCall object. These results provide additional relevant data that the LLM uses when creating its response.

After you create a tool result, you can provide it to subsequent llm.generateText(options) or llm.generateTextStreamed(options) calls, which lets the LLM incorporate the results of the tool call and return a more accurate and relevant response.

Returns

llm.ToolResult

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/llm Module

Since

2025.2

Parameters

Parameter

Type

Required / Optional

Description

Since

options.call

llm.ToolCall

required

The original tool call request from the LLM.

This parameter links the result to a specific tool call request.

2025.2

options.outputs

Object[]

required

An array of output objects representing the results of running the tool.

Each output object typically includes a result property (or another relevant property) that contains the value to send back to the LLM.

2025.2

Syntax

Important:

The following code sample shows the syntax for this member. It isn't a functional example. For a complete script example, see N/llm Module Script Samples.

            // Add additional code
...

const toolResult = llm.createToolResult({
    // toolCall is the originating tool call request from the LLM    
    call: toolCall,
    // handlerResult is the result of running the tool specified by the
    // tool call request
    outputs: [{ result: handlerResult }]
});

...
// Add additional code 

          

Related Topics

General Notices