Skip to content

Search Tools

Search Tools provides AI characters with web search capabilities, allowing characters to retrieve real-time information during conversations and inject search results into the context. The search plugin supports multiple search engine backends and provides two working modes to accommodate different use cases.

Two Working Modes

Tool Mode

Search functionality is registered as a callable tool for the creative LLM in the Function Call Runtime. When the AI determines it needs to search for information, it proactively initiates a tool call.

  • Enabled via the enabled configuration option
  • Registers luker_web_search and luker_web_visit as function tools
  • AI autonomously decides when to search and what to search for
  • Search results are injected into the conversation context as tool call return values

Pre-request Agent Mode

Before the creative LLM generates a response, an independent search Agent runs automatically. The Agent analyzes the current conversation content, determines whether a search is needed, and writes search results into World Info entries.

  • Enabled via the preRequestEnabled configuration option
  • The Agent uses independent LLM presets (agentPresetName) and API presets (agentApiPresetName), which can use different models from the creative LLM
  • Agent maximum execution rounds are controlled by agentMaxRounds
  • Search results are automatically created as World Info entries that the creative LLM can directly read during generation
  • Supports stopping Agent execution via the Stop button on toast notifications

Choosing Between Modes

Tool Mode is suitable for scenarios where the model needs to autonomously decide when to search during conversation — for example, when a user asks "What's in the news lately?" the model will automatically call the search tool to get information. Search behavior is autonomously triggered by the model based on conversation content.

Pre-request Agent Mode automatically executes searches before each AI generation, with the search process completely separated from the main conversation. Suitable for scenarios where you want every response to be backed by the latest information.

Supported Search Engines

Search EngineDescriptionConfiguration Requirements
DuckDuckGoDefault search engine, no API key requiredWorks out of the box
SearXNGSelf-hosted meta search engine, privacy-friendlyRequires self-hosted instance URL
Brave SearchSearch API provided by BraveRequires API key

The search engine is selected via the provider configuration option, with each engine's independent configuration stored in providerSettings. You can also configure the safe search level via safeSearch.

World Info Entry Management

In Pre-request Agent Mode, search results are automatically created as World Info entries. The behavior of these entries can be controlled through the following configuration options:

SettingDescription
lorebookDepthInjection depth of entries in the prompt
lorebookRoleRole marker for entries (e.g., system, assistant)
lorebookEntryOrderSort weight of entries
lorebookPositionInjection position of entries

Search result entries can be set to constant (always active) or activated through keyword matching, depending on the Agent's judgment and configuration.

Global API

The search plugin provides a global API for integration by other plugins. For example, the Character Card Editor has integrated search capabilities, enabling web searches for reference materials in Studio to assist with character card editing.

Properties

PropertyTypeDescription
toolNamesObjectTool name constants object, containing SEARCH and VISIT

Methods

MethodReturn ValueDescription
getToolDefs()ArrayReturns the search tool definition array, including tool names, parameter schemas, etc.
isToolName(name)booleanDetermines whether a given name is a tool name registered by the search plugin
invoke(call, options)PromiseInvokes a search tool; call contains the tool name and parameters
search(args)PromiseDirectly executes a search and returns results
visit(args)PromiseDirectly visits a specified web page and returns page content
getSettings()ObjectReturns a snapshot of current search plugin settings

Usage Example

javascript
const api = Luker.searchTools;
if (api) {
  // Check if it's a search tool
  api.isToolName('luker_web_search'); // true

  // Get tool definitions
  const defs = api.getToolDefs();

  // Directly call search
  const results = await api.search({ query: '...', maxResults: 5 });

  // Visit a web page
  const page = await api.visit({ url: 'https://...', maxChars: 10000 });
}

Result Reuse

The search plugin implements a fine-grained result reuse mechanism to avoid redundant searches in unnecessary scenarios.

The system automatically determines whether the previous search Agent's results can be reused. Reuse requires all of the following conditions to be met:

  1. The current chat key matches the previous snapshot's chat key
  2. The user anchor (characteristics of the last user message) matches the previous snapshot
  3. The current generation type belongs to a reusable type (e.g., regeneration, continue generation scenarios)

When results are reused, the UI displays a (reused) marker, indicating that cached search results were used for this generation.

Impact of Message Operations

The search plugin monitors message deletion and editing events, automatically maintaining internal state consistency:

  • Message deletion — Updates search state based on the range of deleted messages, ensuring no references to search results from deleted messages
  • Message editing — Updates search state based on the edited message position, potentially invalidating cached search results

Configuration Reference

SettingDescription
Enable Search ToolsEnable Tool Mode, allowing the model to autonomously call search during conversation
Enable Pre-request AgentEnable Pre-request Agent Mode, automatically searching before each generation
Search EngineSelect search engine (DuckDuckGo / SearXNG / Brave Search)
Search Result CountNumber of results returned per search
Page Extract CharactersMaximum text length extracted when visiting web pages
Safe SearchSafety filtering level for search results
Agent API PresetAPI connection preset for the pre-request Agent (empty uses main connection)
Agent PresetPreset for the pre-request Agent (empty uses main preset)
Agent Max RoundsMaximum search rounds for the pre-request Agent

Related Pages

Built upon SillyTavern