How to Create Custom Agent Tool Types
To create a custom agent tool type with Vault Java SDK:
-
Create a Tool Type Runtime Handler by implementing
AIToolTypeHandler:@ExecuteAs(ExecuteAsUser.REQUEST_OWNER) @AiContextTypeRuntimeHandlerInfo(scope = AiScope.DOCUMENT) public class MyContextTypeRuntimeHandler implements AiContextTypeRuntimeHandler{ @Override public AiContextTypeResolveResponse onResolve(AiContextTypeResolveContext context){ AiDocumentScopeSource documentScopeSource = context.getScopeSource(AiScopeType.DOCUMENT); DocumentVersion documentVersion = documentScopeSource.getDocumentVersion(); String documentName = documentVersion.getValue("name__v", ValueType.STRING); AiContextTypeOutputItem contextOutput = context.newOutputItemBuilder() .withText("The current document name is [" + documentName + "]") .build(); return context.newSuccessResponseBuilder() .appendOutputItem(contextOutput) .build(); } } -
Create an
Aitooltyperuntimecoderecord referencing theAIToolTypeHandler, and createAitooltyperuntimecodeMDL records:RECREATE Aitooltype my_custom_tool_type__c ( label('My Tool Type'), admin_configurable(true), description ('Sample tool to create a Tool Invocations record'), runtime_code('Aitooltyperuntimecode.com.veeva.vault.custom.context.MyToolTypeRuntimeHandler') );