Skip to content

feat(conversation): add compact.strategy pointer mode - #1629

Merged
edenreich merged 4 commits into
mainfrom
fix/issue-1627
Oct 28, 2026
Merged

edenreich merged 4 commits into
mainfrom
fix/issue-1627

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Resolves #1627

Summary

Adds an opt-in compact.strategy: pointer mode for compaction. With it, a rollover (manual /compact, the auto_at token trigger or the idle trigger) skips the LLM summarizer call entirely and seeds the continued session with a single user message that opens with the context summary marker, names the previous session id, and tells the model to read only what it needs from there via infer conversations show <id>. The model chooses what matters instead of the summarizer deciding up front. The default summary strategy is byte-for-byte unchanged.

Changes

  • config.CompactConfig gains strategy (summary | pointer, default summary), with env var INFER_COMPACT_STRATEGY (viper maps it automatically) and an unknown-value fallback to summary when the optimizer is built.
  • internal/conversation: smartOptimize now builds its checkpoint through a strategy switch. summaryCheckpoint is the moved (unchanged) LLM summary path; pointerCheckpoint reads the previous session id from the wired repo at compaction time - inside performRollover that is before StartNewConversation repoints the repo, so it is exactly the id the session group History records - and skips the client entirely, so no LLM call, no backoff and no summary_max_tokens involvement. The pointer message opens with contextSummaryMarker, so hasCheckpoint and the gated errNoCheckpoint path from [BUG] Session rollover bypasses compaction backoff and rolls over on a failed summary #1592 keep holding.
  • RestoreContext (skill restore) hook runs unchanged in both strategies.
  • internal/container passes the strategy through to the optimizer (single wiring point).
  • docs/configuration-reference.md: documents compact.strategy under Compact Settings, a pointer-mode note in the checkpoint paragraph, and the env var in the Compact Configuration env list.
  • Tests: pointer-mode tests in conversation_optimizer_test.go (no summarizer call, message shape, marker present, restore hook, missing-id fallback, unknown-strategy fallback) and full rollover tests in session_rollover_test.go for all three triggers (manual force, auto_at gated force=false, idle force) with the real optimizer and a nil client, asserting the pointer names the id recorded in the group History and that the pointed-at session still holds the full conversation.

No docs ticket: documentation was updated in-repo (this PR modifies docs/configuration-reference.md, which lives in this repo).

Behind the new compact.strategy: pointer setting, a compaction skips the LLM summarizer call and seeds the continued session with one user message that opens with the context summary marker and names the previous session id, telling the model to pull only what it needs via infer conversations show.

The summary strategy stays the unchanged default. The pointer keeps the optimizer gate, hasCheckpoint and the restore hook working in manual /compact, auto_at and idle rollovers alike.
Comment thread config/config.go Resolved
Replace the untyped strategy constants with a defined CompactStrategy string type and drop the verbose field comment the review flagged, threading the type through the optimizer config and struct so the summary and pointer values are compiler-checked instead of documented in prose
conversations show prints only the first 10 entries by default so a careless read does not flood the context. --no-trunc lifts the cap and --append (-a) prints the entries after the window so a long session can be read in chunks.

Per-entry numbers stay true to the session across windows, truncated output is flagged in text and json, and the commands reference covers the new flags.
@edenreich
edenreich merged commit 6367927 into main Oct 28, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-1627 branch October 28, 2026 18:00
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.239.0-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@edenreich edenreich moved this from Todo to Done in 2026 Oct 29, 2026
@edenreich edenreich added the rc Shipped in a release candidate label Oct 31, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.239.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rc Shipped in a release candidate released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Make compaction a bit more loose behind a feature flag

1 participant