This repository was archived by the owner on May 26, 2026. It is now read-only.
feat: log and optionally display compaction events - #548
Open
just-cameron wants to merge 1 commit into
Open
just-cameron wants to merge 1 commit into
just-cameron wants to merge 1 commit into
Conversation
Handle compaction_start and compaction_summary messages from the SDK
stream. On every compaction, log the before/after token counts, message
counts, and trigger type. When display.showCompaction is enabled in
lettabot.yaml, also send a brief note to the active channel
("Context compacted: 197K -> 64K tokens").
Depends on letta-code-sdk#76 which surfaces event_message and
summary_message through transformMessage().
Written by Cameron ◯ Letta Code
"Not everything that counts can be counted, and not everything that
can be counted counts." -- William Bruce Cameron
Contributor
Author
Blocked on upstreamThis PR depends on letta-code-sdk#76, which is itself blocked on a server-side gap: the conversations API endpoint does not emit compaction events. The legacy Tracking: LET-7913 Once LET-7913 is resolved and SDK letta-ai/letta-agent-sdk#76 is published, this PR needs a version bump commit before merge. |
This branch has not been deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
compaction_startandcompaction_summarySDK message types in bothprocessMessage()andsendToAgent()stream loopsdisplay.showCompactionconfig option to optionally show a brief note in the active channel (e.g. "(Context compacted: 197K -> 64K tokens)")showCompactionto bothDisplayConfigandBotConfig.displayContext
Ed T noticed that compaction events never appear in lettabot logs, making it impossible to know if/when automatic compactions fire on the server. Manual trigger worked (197K -> 64K), but there was no way to verify automatic compaction behavior.
The Letta API already sends
event_messageandsummary_messageduring compaction, but the SDK was silently dropping them. letta-code-sdk#76 fixes the SDK side; this PR consumes the newly-surfaced messages.Config example
Dependencies
Test plan
tsc --noEmit)runId->eventRunIdsis empty -> not filtered)Written by Cameron ◯ Letta Code
"Not everything that counts can be counted, and not everything that can be counted counts." -- William Bruce Cameron