Skip to content
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
mainfrom
feat/compaction-logging
Open

just-cameron wants to merge 1 commit into
mainfrom
feat/compaction-logging

Conversation

@just-cameron

Copy link
Copy Markdown
Contributor

Summary

  • Handle compaction_start and compaction_summary SDK message types in both processMessage() and sendToAgent() stream loops
  • Log before/after token counts, message counts, and trigger type on every compaction
  • Add display.showCompaction config option to optionally show a brief note in the active channel (e.g. "(Context compacted: 197K -> 64K tokens)")
  • Add showCompaction to both DisplayConfig and BotConfig.display

Context

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_message and summary_message during 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

features:
  display:
    showCompaction: true  # optional, default false

Dependencies

  • Requires letta-code-sdk#76 to be merged and published

Test plan

  • Type-checks clean (tsc --noEmit)
  • Verified foreground run filter passes compaction messages through (no runId -> eventRunIds is empty -> not filtered)
  • Manual test with a compaction event after SDK bump

Written by Cameron ◯ Letta Code

"Not everything that counts can be counted, and not everything that can be counted counts." -- William Bruce Cameron

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
@just-cameron

just-cameron commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

Blocked on upstream

This 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 agents/{id}/messages/stream endpoint works correctly.

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

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant