**Source URL:** https://limited.veevavault.dev/qualityone/ai-agents/agent-context/how-to-create-custom-context-type

# How to Create Custom Context Types

<Aside type="note">
The functionality described on this page is only available to customers who have licensed Vault AI.
</Aside>

To create a custom context type with Vault Java SDK:

<Steps>
1.  Create a *Context Type Runtime Handler*:
    
    ```java
    @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 `Aicontexttyperuntimecode` MDL record referencing the `AiContextTypeRuntimeHandler`, and create an `Aicontexttype` MDL record:
    
    ```sql
    RECREATE Aicontexttype my_custom_context_type__c (
    label('My Context Type'),
    admin_configurable(true),
    runtime_code('Aicontexttyperuntimecode.com.veeva.vault.custom.context.MyContextTypeRuntimeHandler')
          );
    ```
</Steps>

---

**Previous:** [Agent Context](/qualityone/ai-agents/agent-context)  
**Next:** [Agent Tools](/qualityone/ai-agents/agent-tools)