Table of Contents

Method SummarizeConversationAsync

Namespace
LMKit.Agents
Assembly
LM-Kit.NET.dll

SummarizeConversationAsync(ChatHistory, LM, string, CancellationToken)

Summarizes a conversation into episodic memory entries that capture the key topics, decisions, and outcomes discussed.

public Task<ConversationSummaryResult> SummarizeConversationAsync(ChatHistory chatHistory, LM summarizationModel, string dataSourceIdentifier = "conversation_episodes", CancellationToken cancellationToken = default)

Parameters

chatHistory ChatHistory

The chat history to summarize. Only User and Assistant messages are included.

summarizationModel LM

The language model used to generate the summary.

dataSourceIdentifier string

The data source where episodic entries are stored. Default is "conversation_episodes".

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<ConversationSummaryResult>

A ConversationSummaryResult describing what was stored.

Examples

Example: Summarizing a session before exit

// At the end of a session
var result = await memory.SummarizeConversationAsync(
    executor.ChatHistory, chatModel);

Console.WriteLine($"Stored {result.EntriesCreated} episodic memories.");
foreach (var summary in result.Summaries)
    Console.WriteLine($"  - {summary}");

memory.Serialize("agent_memory.bin");

Remarks

Call this method at the end of a session (before disposing the conversation or agent) to preserve a compressed record of the interaction. The resulting entries are stored as Episodic memory with metadata containing the conversation_id and message_count.

The LLM is prompted to produce up to MaxConversationSummaries concise summaries, each capturing a distinct topic or outcome from the conversation. Short conversations (fewer than 2 user messages) are skipped.

Exceptions

ArgumentNullException

Thrown when chatHistory or summarizationModel is null.