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

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.

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.

Behavior details

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