Sanity Library Reference Docs
    Preparing search index...

    Interface AgentSettings

    Settings for creating an agent instance (per-thread).

    Passed as the second argument to contentAgent.agent(threadId, settings).

    const model = contentAgent.agent('my-thread-id', {
    application: { key: 'projectId.datasetName' },
    config: {
    capabilities: { read: true, write: false },
    },
    })
    interface AgentSettings {
        application?: {
            bundleVersion?: string;
            intentBaseUrl?: string;
            key?: string;
            name?: string;
            resource?: { id?: string; type?: "dataset" };
            schemaDescriptorId?: string;
            title?: string;
        };
        clientId?: string;
        config?: {
            capabilities?: {
                features?: { webSearch?: boolean };
                read?: boolean | { preset: "minimal" | "standard" };
                write?: boolean | { preset: "minimal" | "standard" };
            };
            filter?: { read?: string; write?: string };
            instruction?: string;
            perspectives?: { read?: string[]; write?: string };
            userMessageContext?: { [key: string]: string };
        };
        format?: "markdown"
        | "directives";
        onStreamData?: (type: string, data: unknown) => void;
    }

    Hierarchy

    • BaseAgentSettings
      • AgentSettings
    Index

    Properties

    application?: {
        bundleVersion?: string;
        intentBaseUrl?: string;
        key?: string;
        name?: string;
        resource?: { id?: string; type?: "dataset" };
        schemaDescriptorId?: string;
        title?: string;
    }

    Target Sanity application configuration.

    Type declaration

    • OptionalbundleVersion?: string

      Bundle version

    • OptionalintentBaseUrl?: string

      Format: uri

      Base URL for the Sanity Studio

      https://your-studio.sanity.studio
      
    • Optionalkey?: string

      Application key in format "projectId.datasetName"

      abc123.production
      
    • Optionalname?: string

      Application name

    • Optionalresource?: { id?: string; type?: "dataset" }
      • Optionalid?: string

        Resource ID in format "projectId.datasetName"

        abc123.production
        
      • Optionaltype?: "dataset"

        Resource type

    • OptionalschemaDescriptorId?: string

      Schema descriptor ID

    • Optionaltitle?: string

      Application title

    clientId?: string

    Identifies the client that created the thread (e.g. 'slack', 'linear', 'dashboard').

    Stored in thread metadata and used by the dashboard to filter its thread list. When omitted, the server assigns a default value.

    config?: {
        capabilities?: {
            features?: { webSearch?: boolean };
            read?: boolean | { preset: "minimal" | "standard" };
            write?: boolean | { preset: "minimal" | "standard" };
        };
        filter?: { read?: string; write?: string };
        instruction?: string;
        perspectives?: { read?: string[]; write?: string };
        userMessageContext?: { [key: string]: string };
    }

    Agent configuration for controlling behavior, capabilities, and document access.

    Type declaration

    • Optionalcapabilities?: {
          features?: { webSearch?: boolean };
          read?: boolean | { preset: "minimal" | "standard" };
          write?: boolean | { preset: "minimal" | "standard" };
      }
      • Optionalfeatures?: { webSearch?: boolean }
        • OptionalwebSearch?: boolean

          Override web search availability. By default, web search is enabled when read capability is 'standard'.

      • Optionalread?: boolean | { preset: "minimal" | "standard" }
      • Optionalwrite?: boolean | { preset: "minimal" | "standard" }
    • Optionalfilter?: { read?: string; write?: string }
      • Optionalread?: string

        GROQ boolean expression for document visibility. Documents matching this filter are visible to the agent.

        _type in ['post', 'author']
        
      • Optionalwrite?: string

        GROQ boolean expression for mutation permissions. Documents matching this filter can be mutated.

        _type == 'post'
        
    • Optionalinstruction?: string

      Custom instruction string to include in the system prompt

      You are a helpful content assistant.
      
    • Optionalperspectives?: { read?: string[]; write?: string }
      • Optionalread?: string[]

        Allowed read perspectives. When set, query tools can only use these perspectives. If the agent tries to use a disallowed perspective, the request is rejected with an error.

        [
        "drafts",
        "published"
        ]
      • Optionalwrite?: string

        The write perspective. When set, new documents are created in this perspective and mutations are restricted to documents whose ID matches it.

        drafts
        
    • OptionaluserMessageContext?: { [key: string]: string }

      Key-value pairs appended to each user message as XML tags. Each key becomes an XML tag with the value as content. Example: { "slack-channel": "#marketing" } renders as #marketing

      {
      * "slack-channel": "#marketing",
      * "user-role": "editor"
      * }
    format?: "markdown" | "directives"

    Controls how directives in the response are formatted.

    • markdown (default): Directives are resolved server-side into standard markdown.
    • directives: Raw directive syntax is preserved for clients that render custom UI.
    'markdown'
    
    onStreamData?: (type: string, data: unknown) => void

    Called when a custom data-* SSE part arrives during streaming.

    Type declaration

      • (type: string, data: unknown): void
      • Parameters

        • type: string

          The data part type with the data- prefix stripped (e.g. 'agent-status').

        • data: unknown

          The parsed payload.

        Returns void