Skip to content

feat: summarize on-going convo histories and convo themes#24

Merged
canefe merged 15 commits intodevfrom
claude/summarize-message-history-0azys
Mar 13, 2026
Merged

feat: summarize on-going convo histories and convo themes#24
canefe merged 15 commits intodevfrom
claude/summarize-message-history-0azys

Conversation

@canefe
Copy link
Owner

@canefe canefe commented Mar 8, 2026

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

claude added 2 commits March 8, 2026 05:22
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
@gemini-code-assist

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
gemini-code-assist[bot]

This comment was marked as resolved.

claude added 5 commits March 8, 2026 17:37
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
gemini-code-assist[bot]

This comment was marked as resolved.

…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
gemini-code-assist[bot]

This comment was marked as resolved.

claude and others added 5 commits March 9, 2026 05:04
- 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
@canefe canefe changed the base branch from main to dev March 13, 2026 06:59
@canefe canefe changed the title feat: summarize conversation message history every 5 messages feat: summarize on-going conversation histories and conversation themes Mar 13, 2026
@canefe canefe changed the title feat: summarize on-going conversation histories and conversation themes feat: summarize on-going convo histories and convo themes Mar 13, 2026
@canefe canefe merged commit 869a9ad into dev Mar 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants