Skip to main content
Stores and retrieves a chat’s message history and tools configuration.

Constructor

new ContextManager(cache: ICache, options?: ContextManagerOptions)
OptionTypeDescription
cacheKeyPrefixstringKey prefix for cache entries (default: "illa:sdk:ctx")
cacheEntryOptionsCacheEntryOptionsDefault TTL settings forwarded to the cache
defaultToolsConfigToolAutorouterRequestDefault tool routing config returned when no data is stored

Methods

  • getContext(chatId): Promise<{ messages, toolsConfig }>
  • clearContext(chatId): Promise<void>
  • setMessages(chatId, messages): Promise<void>
  • appendMessages(chatId, messages): Promise<void>
  • setToolsConfig(chatId, toolsConfig): Promise<void>
  • deleteContext(chatId): Promise<void>
Notes:
  • clearContext resets message history and tools config to defaults for a chat but keeps the chat ID registered. Use deleteContext to remove everything including the cache entry.
  • The manager deep‑clones stored data to avoid accidental mutation by callers.

Example

const snapshot = await chat.getContext()
await chat.setContext(snapshot)