3.16 SET_TOOL_RESULT Procedure Signature 1

This procedure dynamically changes the result of the "Execute Server-side Code" and "Retrieve Data" Generative AI Tools.

Both tool types can show a declarative notification message upon completion. To override this notification message or its type, pass p_notification_message or p_notification_type.

The "Execute Server-side Code" tool does not typically return a value, with "success" being passed under the hood. To override this message, pass a custom p_result.

Syntax

PROCEDURE apex_ai.set_tool_result (
    p_result                 IN   CLOB                 DEFAULT NULL,
    p_notification_message   IN   VARCHAR2             DEFAULT NULL,
    p_notification_type      IN   t_notification_type  DEFAULT NULL,
    p_early_exit             IN   BOOLEAN              DEFAULT FALSE,
    p_is_safe                IN   BOOLEAN              DEFAULT FALSE
 );

Parameters

Parameter Description
p_result

A dynamic tool call result. Only relevant in the "Execute Server-side Code" tool which does not usually return a result.

p_notification_message

An optional notification message, overriding the declarative notification message

p_notification_type

An optional notification type, overriding the declarative notification type

p_early_exit

Whether to short circuit the communication and not return to the AI Service upon tool call completion. Defaults to false.

p_is_safe

Whether the tool result is safe to send to the AI Service without prompt-injection guard wrapping. Defaults to false.

Example

If the tool action cannot be completed, provides both a visual notification and a tool response message to maintain integrity of the chat history, which is important for subsequent requests. Also passing p_early_exit, as to not return to the AI Service, therefore sparing one network request, and lowering the response time.

apex_ai.set_tool_result (
     p_result                => 'Email could not be sent',
     p_notification_message  => 'Email could not be sent',
     p_notification_type     => apex_ai.c_notification_type_error,
     p_early_exit            => true );