Skip to content

feat(conversation-memory): reduce token usage in summarization - #397

Merged
baleen37 merged 2 commits into
mainfrom
fix/reduce-converstation
Feb 5, 2026
Merged

feat(conversation-memory): reduce token usage in summarization#397
baleen37 merged 2 commits into
mainfrom
fix/reduce-converstation

Conversation

@baleen37

@baleen37 baleen37 commented Feb 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Increase chunk size from 8 to 32 exchanges (~75% fewer API calls)
  • Skip agent/subagent conversations (files starting with agent-)
  • Add characterization tests for the new behavior

Test plan

  • Build passes: npm run build
  • Tests pass: npm test (9 tests)
  • Code changes verified in dist output

Expected impact

  • 1765 exchanges: 222 API calls → 56 API calls (~75% reduction)
  • 400 exchanges: 51 API calls → 13 API calls (~75% reduction)
  • Agent/subagent conversations are now skipped during indexing

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Agent-generated files are now excluded from conversation indexing and sync operations.
  • Performance Improvements

    • Increased conversation chunk size from 8 to 32 exchanges, reducing API calls for large conversations.
  • Tests

    • Added test coverage for file filtering and conversation chunking logic.

baleen37 and others added 2 commits February 5, 2026 09:04
- Increase chunk size from 8 to 32 exchanges (~75% fewer API calls)
- Skip agent/subagent conversations (files starting with 'agent-')

This reduces both API costs and processing time for large conversation
histories while maintaining summary quality.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…tion

- Add test framework (Bun test)
- Add tests for chunk size (32 exchanges per chunk)
- Add tests for agent- file filtering behavior
- Add npm test script

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@baleen37
baleen37 enabled auto-merge February 5, 2026 00:08
@coderabbitai

coderabbitai Bot commented Feb 5, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces filtering to exclude agent-generated files (prefixed with "agent-") from indexing and sync operations, increases the hierarchical summarization chunk size from 8 to 32 exchanges to optimize API calls, adds comprehensive test suites for filtering and chunking logic, and sets up a test script in package.json.

Changes

Cohort / File(s) Summary
Test Infrastructure
plugins/conversation-memory/package.json
Added "test" script using bun test for running test suites.
Indexer Logic
plugins/conversation-memory/src/core/indexer.ts, plugins/conversation-memory/src/core/indexer.test.ts
Implemented filtering to exclude files starting with "agent-" in indexConversations, indexSession, and indexUnprocessed. Added test suite validating filter behavior across multiple scenarios.
Summarizer Logic
plugins/conversation-memory/src/core/summarizer.ts, plugins/conversation-memory/src/core/summarizer.test.ts
Increased chunk size from 8 to 32 exchanges in hierarchical summarization to reduce API calls. Added test suite validating chunking behavior with various input sizes.
Sync Logic
plugins/conversation-memory/src/core/sync.ts
Updated file collection logic to exclude files starting with "agent-" when listing JSONL files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Suggested labels

enhancement

Poem

🐰 A bunny hops through code so neat,
Filters out those agent treats,
Chunks grow large, from eight to thirty-two,
Tests ensure it all rings true! 🎉

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/reduce-converstation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@baleen37
baleen37 merged commit d921bc7 into main Feb 5, 2026
4 of 5 checks passed
@baleen37
baleen37 deleted the fix/reduce-converstation branch February 5, 2026 00:08
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.

1 participant