fix: compact() leaves stale thoughts, ingestBatch() is sequential, trimToBudget() iterates unnecessarily #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code review findings — must fix before production use:
1. compact() doesn't clean up summarized thoughts
After writing summary thought, original individual thoughts remain in OpenBrain.
Unbounded storage growth over time; listRecent() returns stale messages already covered by summaries.
Fix: after writing summary, delete or mark the thoughts that were summarized.
2. ingestBatch() is sequential
Awaits each ingest() call in a for loop. Bootstrapping 50 messages = 50 serial HTTP calls.
Fix: use Promise.all (with concurrency cap e.g. p-limit or simple batching).
3. trimToBudget() skips instead of stops
Uses continue instead of break when a message exceeds budget.
Iterates full array unnecessarily when budget is exhausted early.
Fix: break on first message that won't fit (iterating newest-to-oldest).