Skip to main content
The history tool gives models long-term memory that persists across sessions. When enabled, every request-response pair is automatically stored and indexed. The model can then semantically search past interactions to recall information from earlier conversations.

How it works

  1. Add { type: "history" } to the tools array in your request
  2. The model receives a history function it can call with a search query
  3. Past conversations are searched using vector embeddings for semantic similarity
  4. After each response completes, the user message and assistant reply are stored automatically in the background
Memory is scoped per end-user — each X-On-Behalf-Of user ID gets an isolated history store. Different end-users cannot see each other’s history.

Enable the history tool

import { SDK } from '@meetkai/mka1';

const mka1 = new SDK({
  bearerAuth: `Bearer ${YOUR_API_KEY}`,
});

const result = await mka1.llm.responses.create({
  model: 'meetkai:functionary-swahili-large',
  input: 'Remember this: my favorite color is blue.',
  tools: [{ type: 'history' }],
  store: true,
}, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });
Set store: true so the conversation is persisted and available for future recall.

Recall information from a previous session

In a later request — even minutes, hours, or days later — the model can search its history to find relevant past interactions. The model decides when to call the history tool based on the user’s question.
// In a new session, the model can recall past conversations
const result = await mka1.llm.responses.create({
  model: 'meetkai:functionary-swahili-large',
  input: 'What is my favorite color?',
  tools: [{ type: 'history' }],
  store: true,
}, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });

// The model calls the history tool, finds the earlier conversation,
// and responds: "Your favorite color is blue."

Full example: store and retrieve across sessions

This example shows the complete flow — storing information in one request and retrieving it in a separate request.
import { SDK } from '@meetkai/mka1';

const mka1 = new SDK({
  bearerAuth: `Bearer ${YOUR_API_KEY}`,
});

const headers = { 'X-On-Behalf-Of': 'user-123' };

// Session 1: Tell the model something to remember
const first = await mka1.llm.responses.create({
  model: 'meetkai:functionary-swahili-large',
  input: 'Remember this: the project deadline is March 15th and the budget is $50,000.',
  tools: [{ type: 'history' }],
  store: true,
}, { headers });

console.log('Stored:', first.outputText);

// Session 2: Ask about it later
const second = await mka1.llm.responses.create({
  model: 'meetkai:functionary-swahili-large',
  input: 'What is the project deadline and budget?',
  tools: [{ type: 'history' }],
  store: true,
}, { headers });

console.log('Recalled:', second.outputText);
// → "The project deadline is March 15th and the budget is $50,000."

Behavior details

AspectDetail
StorageAutomatic — each request/response pair is indexed after the response completes
SearchSemantic — uses vector embeddings, not keyword matching
ScopePer end-user — isolated by X-On-Behalf-Of header
IndexingBackground — does not add latency to the response
ResultsUp to 10 most relevant past interactions returned per search
Entry sizeText truncated to 7,500 characters per entry for embedding

When to use the history tool

  • Personalization: Remember user preferences, names, or context across sessions
  • Project continuity: Recall decisions, deadlines, or requirements discussed earlier
  • Support workflows: Maintain context about a user’s issue history
  • Assistants: Build assistants that learn and adapt to individual users over time

Next steps