feat: summarize on-going convo histories and convo themes#24
Merged
Conversation
Automatically condenses older conversation messages into a summary when 5 new conversational messages accumulate. This keeps the AI context window manageable for long conversations while preserving important context through summarization. - Add messagesSinceLastSummary counter to Conversation - Add replaceHistoryWithSummary() to swap old messages with a summary - Add checkAndSummarizeHistory() to ConversationManager - Trigger summarization after player messages and NPC responses - Add message_history_summary prompt to prompts.yml - Add getMessageHistorySummaryPrompt() to PromptService https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
Add conversation.summarizationThreshold to ConfigService and config.yml so server admins can tune how often message history gets summarized. Defaults to 5 messages. https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
This comment was marked as resolved.
This comment was marked as resolved.
Tests cover: - Message counter increments for player/NPC messages - Counter ignores system messages and "..." placeholders - replaceHistoryWithSummary resets counter and replaces history - Summarization triggers at configurable threshold - Summarization keeps recent messages and replaces old ones - Configurable threshold is respected - Graceful handling of null/failed AI responses - Counter resets after summarization allowing re-trigger https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
Draft architecture for a theme system that supports stackable, registry-based conversation themes with compatibility checks. https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
The async summarization could lose messages added while the AI was generating a summary. replaceHistoryWithSummary previously cleared the entire history and replaced it with a stale snapshot, wiping any messages added during the async window. Changes: - Conversation.replaceHistoryWithSummary now takes a count of summarized messages and removes only those from the front of the history, preserving any messages appended concurrently. - checkAndSummarizeHistory now dispatches the history replacement back to the main server thread via Bukkit.getScheduler().runTask() to ensure thread safety. - Updated and added tests covering the race condition scenario. https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
- Use subList(0, count).clear() instead of repeat/removeAt(0) for O(n) instead of O(n²) removal. - Decrement messagesSinceLastSummary by summarized count instead of resetting to 0, so messages added during the async window are accurately reflected in the counter. - Add guard clause: no-op when count <= 0 or exceeds history size. - Remove private set from messagesSinceLastSummary to allow decrement. - Add test for no-op boundary condition and update counter assertions. https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
Implement a pluggable theme architecture for conversations: - ConversationTheme abstract base with lifecycle hooks - ConversationThemeFactory for theme instantiation - ConversationThemeRegistry for registering available themes - ConversationThemeManager for per-conversation theme activation with compatibility checks - ConversationThemeData on Conversation for tracking active themes - ChatTheme (default, compatible with all) and ViolenceTheme (combat, compatible with chat only) - Tests for registry and manager https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
…zation - Call themeManager.onConversationEnd in completeEndConversation to prevent theme state from leaking for ended conversations - Add clearThemeNames() to ConversationThemeData for cleaner cleanup - Guard checkAndSummarizeHistory against concurrent summarization requests using a summarizingConversations set - Add history.size <= recentMessagesToKeep guard to prevent negative splitIndex causing IllegalArgumentException - Sanitize role prefixes in summarization input using bracketed labels and stripping newlines to prevent role spoofing - Fix messagesSinceLastSummary decrement to only count non-system, non-placeholder messages that were actually counted toward the threshold - Prefix summaries with "Summary of conversation so far:" to distinguish AI-generated summaries from system instructions https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
- Use Collections.synchronizedSet for summarizingConversations, matching the pattern used by endingConversations - Use ConcurrentHashMap + CopyOnWriteArrayList for activeThemes in ConversationThemeManager to handle concurrent access safely https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automatically condenses older conversation messages into a summary
when 5 new conversational messages accumulate. This keeps the AI
context window manageable for long conversations while preserving
important context through summarization.
https://claude.ai/code/session_015f6QcQHuGmUtxHLS1mGahA