Skip to content

How to Create Custom Agent Tool Types

To create a custom agent tool type with Vault Java SDK:

  1. 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(); } }
  2. Create an Aitooltyperuntimecode record referencing the AIToolTypeHandler, and create Aitooltyperuntimecode MDL 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') );