Skip to content

transcriptSearchTool

JavaScript · package toolnexus · SPEC §7E · js/src/transcript_search.ts

function transcriptSearchTool(store: ConversationStore, opts?: TranscriptSearchOptions): Tool
interface TranscriptSearchOptions { maxResults?: number; snippetChars?: number; name?: string }

transcriptSearchTool turns a conversation store into a plain, read-only tool named transcript_search. The model calls it with {query, conversationId?, limit?}. It does a case-insensitive substring match over the text of every message: plain content, text parts, tool-call arguments (as JSON) and tool-result text. Conversations come in the order the store’s list() returns them (newest first), and messages in index order.

The output is one line per hit, <conversationId>#<index> <role>: <snippet>. The snippet is centred on the first match, snippetChars characters long (characters, not bytes), with … marking cut text. No hits gives no matches. Hits past the limit add a final (+<k> more). An empty query is an error. The tool never writes. Construction fails if the store has no list().

Use it wherever an agent needs to check what actually happened rather than what it remembered: the dreamer uses it to verify memory, and a persona can use it to answer “what did I tell you about X last month?”.

It does not exclude anything by default. To hide the current conversation, give it a store that filters it out.

1. The smallest useful call — search everything

Section titled “1. The smallest useful call — search everything”
import { FileConversationStore, transcriptSearchTool } from "toolnexus"
const search = transcriptSearchTool(new FileConversationStore("./data/conversations"))
const res = await search.execute({ query: "mt. moon" })
console.log(res.output)
// conv-42#3 user: …we finally got through Mt. Moon after the Zubat swarm…
// (or "no matches")
Section titled “2. The realistic case — give a persona its own transcript search”
import { agents, FileConversationStore, transcriptSearchTool } from "toolnexus"
const store = new FileConversationStore("./data/conversations")
// Let the persona itself look up what was actually said, not just what it remembered.
const ava = agents.fromDir("./personas/ava", { tools: [transcriptSearchTool(store)] })

3. The full surface — options and the narrower inputs

Section titled “3. The full surface — options and the narrower inputs”
import { FileConversationStore, transcriptSearchTool } from "toolnexus"
const search = transcriptSearchTool(new FileConversationStore("./data/conversations"), {
maxResults: 5, // ceiling for the `limit` input
snippetChars: 80, // code points, not bytes
name: "past_chats",
})
const res = await search.execute({ query: "invoice", conversationId: "conv-42", limit: 3 })
console.log(res.output) // at most 3 lines, then "(+<k> more)" if there were more
Option Default What it does
maxResults 20 Most hits per call, and the ceiling for the limit input.
snippetChars 200 Snippet length in characters (code points), not bytes.
name transcript_search The tool name the model sees.

Input fields the model fills in:

Field Type What it does
query string Required, non-empty. Case-insensitive substring.
conversationId string Search only this conversation.
limit integer Fewer hits than maxResults.
  • dreamer — the built-in agent that verifies memory with this tool.
  • Dreaming guide — why transcripts are the ground truth for memory.
  • memoryTool — what the transcripts are checked against.