Skip to Content

Class Toolset

Every memory operation as a tool, in the shape a framework wants it.

The to* methods hand the same tools to a particular framework, and Toolset.call runs the one a model named — which is what the definition-only shapes need, since there the host dispatches rather than the framework.

const toolset = session.tools()

// The tools go to the provider as plain data.
const response = await anthropic.messages.create({
model,
max_tokens: 1024,
messages,
tools: toolset.toAnthropic()
})

// Hand a tool call straight back. Only a malformed request or a handle
// nothing answers to comes back as text; anything else throws.
const text = await toolset.call(block.name, block.input)
Index
tools: readonly Tool[]

The tools, in the order a task uses them.

  • Iterate the tools, so a toolset stands in for the array it holds.

    Returns Iterator<Tool>

  • Describe these tools for the OpenAI Chat Completions API.

    Definitions only — pair them with Toolset.call to run what the model asks for, which also takes the JSON string that API hands back. Anything speaking the same shape takes these too; the Responses API wants a flatter one and is not what this emits.

    Returns OpenAITool[]

    One tool definition per operation.

  • Hand these tools to LangChain.

    @langchain/core takes a JSON Schema wherever it takes a Zod schema — the tool() overload set names JsonSchema7Type beside the Zod ones — so the schema is passed through unchanged and this package needs no Zod dependency to build one.

    Returns Promise<any[]>

    One LangChain tool per operation, ready for createAgent({ tools }).

    MemcoConfigError If LangChain is not installed.

    createAgent({ model, tools: await session.tools().toLangChain() })
    
  • Run the tool a model named, and render what it returned.

    Parameters

    • name: string

      The tool name the model used, which is untrusted.

    • args: string | Record<string, unknown>

      The arguments it sent, which are untrusted. An object, or the JSON text OpenAI hands back.

    Returns Promise<string>

    The result as text, or what the model got wrong. Nothing a model can send reaches the caller as an exception.

    await toolset.call('memco_search', { query: 'how does X work' })
    await toolset.call(call.function.name, call.function.arguments) // OpenAI