chat_search
Search stored conversation content using semantic matching to find relevant messages based on meaning, not just keywords. Filter results by project or specific session.
Instructions
Semantic search over all stored conversation content using vector similarity. Finds messages relevant to the query even if exact words don't match. Optionally scope to a project or specific session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Natural language search query. | |
| project | No | Scope search to sessions with this project tag. | |
| limit | No | Maximum number of results. Default: 10. | |
| sessionId | No | Scope search to a single session UUID. |
Implementation Reference
- src/layers/search.ts:13-33 (handler)The core search function that implements the chat_search tool logic. It takes a ChatAdapter, query string, and options (project, sessionId, limit), embeds the query using the adapter, and performs vector search on stored messages.
export async function search( adapter: ChatAdapter, query: string, opts: { project?: string; sessionId?: string; limit?: number; }, ): Promise<SearchResult[]> { const limit = opts.limit ?? 10; // Embed the query text const queryVector = await adapter.embed(query); // Search Qdrant return adapter.searchMessages(queryVector, { project: opts.project, sessionId: opts.sessionId, limit, }); } - src/app.ts:239-271 (registration)Registration of the chat_search tool in the tools array. Defines the tool name, description, input schema (with query, project, limit, sessionId parameters), and delegates execution to layers.search.search().
{ name: "chat_search", description: "Semantic search over all stored conversation content using vector similarity. Finds messages relevant to the query even if exact words don't match. Optionally scope to a project or specific session.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Natural language search query.", }, project: { type: "string", description: "Scope search to sessions with this project tag.", }, limit: { type: "number", description: "Maximum number of results. Default: 10.", }, sessionId: { type: "string", description: "Scope search to a single session UUID.", }, }, required: ["query"], }, execute: async (args) => layers.search.search(adapter, args.query as string, { project: args.project as string | undefined, sessionId: args.sessionId as string | undefined, limit: args.limit as number | undefined, }), }, - src/app.ts:243-264 (schema)Input schema definition for the chat_search tool. Validates required 'query' parameter and optional 'project', 'limit', and 'sessionId' parameters with their types and descriptions.
inputSchema: { type: "object", properties: { query: { type: "string", description: "Natural language search query.", }, project: { type: "string", description: "Scope search to sessions with this project tag.", }, limit: { type: "number", description: "Maximum number of results. Default: 10.", }, sessionId: { type: "string", description: "Scope search to a single session UUID.", }, }, required: ["query"], }, - src/types.ts:58-60 (schema)Type definition for SearchResult output type, which extends ChatMessage with a score field for semantic search relevance ranking.
export interface SearchResult extends ChatMessage { score: number; }