Skip to content

fix(services): Prevent compact summary truncation at 200-token cap#457

Merged
edenreich merged 2 commits intomainfrom
fix/compact-summary-truncation
Apr 27, 2026
Merged

fix(services): Prevent compact summary truncation at 200-token cap#457
edenreich merged 2 commits intomainfrom
fix/compact-summary-truncation

Conversation

@edenreich
Copy link
Copy Markdown
Contributor

@edenreich edenreich commented Apr 27, 2026

Summary

  • GenerateLLMSummary hardcoded maxTokens := 200 and ignored FinishReason, so when the model hit the cap the truncated mid-sentence text was rendered as a complete --- Context Summary --- block. Raise the default to 1024 and expose it as compact.summary_max_tokens for tuning.
  • Warn-log when response.Choices[0].FinishReason == sdk.Length so future truncations are visible in logs instead of failing silently.
  • Bug surfaced after fix(services): Trigger auto-compact from gateway-reported tokens #454 (fix(services): Trigger auto-compact from gateway-reported tokens) made auto-compact actually fire on the gateway-reported token count — the 200-cap was always too tight, but compaction rarely triggered before, so the truncation was rarely visible.

The summary was hardcoded at 200 max tokens with no FinishReason check,
so when the model hit the cap the truncated mid-sentence text was rendered
as a complete summary. Raise the default to 1024, expose it as
compact.summary_max_tokens, and warn-log on FinishReason=length.
@edenreich edenreich merged commit 36b9612 into main Apr 27, 2026
5 checks passed
@edenreich edenreich deleted the fix/compact-summary-truncation branch April 27, 2026 14:44
ig-semantic-release-bot Bot pushed a commit that referenced this pull request Apr 27, 2026
## [0.104.2](v0.104.1...v0.104.2) (2026-04-27)

### 🐛 Bug Fixes

* **services:** Prevent compact summary truncation at 200-token cap ([#457](#457)) ([36b9612](36b9612)), closes [#454](#454)
* Reconcile token displays and persist metadata-only saves ([#459](#459)) ([8bc8767](8bc8767))

### 📚 Documentation

* Update agents MD ([#458](#458)) ([27bfaea](27bfaea))

### 🧹 Maintenance

* **nix:** Update package to v0.104.1 ([#456](#456)) ([784e4bc](784e4bc))
@ig-semantic-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.104.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant