Repository navigation
Labels
Description
Summary
Compaction today summarizes the whole tail of the session with an extra LLM call and starts a new session seeded with that summary (rollover). This is expensive and sometimes loses what mattered: the summarizer decides up front what to keep.
Add an opt-in alternative behind a feature flag: on compaction (manual /compact, the auto_at token trigger, or the idle trigger) do not summarize at all. Start the new session as today, but seed it with a single short user message that says the full context lives in the previous session and gives its id, so the model can pull only what it needs from there. The model chooses what is important instead of the summarizer choosing for it.
Current behavior
internal/conversation/session_rollover.go-performRollovercallsoptimizer.OptimizeMessages(messages, model, force), thenStartNewConversationand re-adds the optimized messages. It keeps the session when a gated run returns no checkpoint (errNoCheckpoint).internal/conversation/conversation_optimizer.go-smartOptimizekeeps the firstcompact.keep_first_messagesmessages, sends the rest (truncated per message) toGenerateLLMSummarywith a 60s timeout, and emits one user-role message opening with--- Context Summary ---(contextSummaryMarker).hasCheckpointlooks for that marker. The optionalrestorehook re-emits loaded skills after the checkpoint.config/config.go-CompactConfighasenabled,auto_at,keep_first_messages,rollover_on_idle_minutes,summary_max_tokens(defaultstrue,80,2,30,1024).- The previous session stays on disk and is readable with
infer conversations show <session-id>(cmd/conversations/conversations.go, supports--include-hiddenand--format json), and the session group index already records the previous id inHistory(updateGroupIndex), so a pointer back to it is enough for the model to read it.
Proposed behavior
- New flag in
CompactConfig, e.g.compact.strategy: summary | pointer(defaultsummary, current behavior unchanged), with the matchingINFER_COMPACT_STRATEGYenv var. - With
pointer: skipGenerateLLMSummary. Keep the samekeep_first_messageshead and therestorehook output, then add one user message along the lines of: "The earlier part of this conversation is stored in session<previous-id>. Runinfer conversations show <previous-id>if you need details from it." Open it withcontextSummaryMarkersohasCheckpointand the gate inperformRolloverkeep working. - No LLM call, no backoff state, no
summary_max_tokensinvolvement in this mode.
Acceptance Criteria
-
compact.strategy(or equivalent flag) is added toCompactConfig, defaults to the current summary behavior, and is documented indocs/configuration-reference.mdunder Compact Settings and the env var list. - With the flag set to the pointer mode,
/compact, theauto_attrigger and the idle trigger each roll over into a new session without callingGenerateLLMSummary, and the new session contains the kept head, one pointer message naming the previous session id, and the restore hook messages. - The pointer message starts with
contextSummaryMarkersohasCheckpointstill detects the rollover and the gated token-trigger path does not returnerrNoCheckpoint. - The previous session id in the pointer message is the one the session group
Historyrecords, andinfer conversations show <id>on it returns the full earlier conversation. - Unit tests in
internal/conversation/session_rollover_test.goandconversation_optimizer_test.gocover the pointer mode (no client call, message shape, marker present).
Related
- [BUG] Session rollover bypasses compaction backoff and rolls over on a failed summary #1592 (closed) - rollover must respect the optimizer gate; the pointer mode still has to return a checkpoint-shaped message so that fix keeps holding.
- [BUG] Auto-compaction over-estimates context and re-fires every turn after a failed summary #1581 (closed) - failed-summary re-fire; not reachable in pointer mode since no summary is generated.
- [FEATURE] Re-check session rollover inside the 'infer agent' turn loop #549 (closed) - rollover re-check inside the agent loop; unchanged by this feature.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
edenreich commentedon Oct 28, 2026
@infer can you work on this? use /ponytail:ponytail /domain-driven-design /clean-architecture /go /go-concurrency
inference-gateway-maintainer commentedon Oct 28, 2026
Model:
ollama_cloud/glm-5.3-flash· Action:v0.59.1· CLI:v0.237.0· Gateway:v0.60.1· View JobTodos
Pull Request
#1629
✅ Infer Result: Success
All done. Issue #1627 is implemented and PR #1629 (ready for review) carries the change.
What changed
PR: #1629 (
fix/issue-1627, commit1bd60657, Conventional Commitfeat(conversation)so semantic-release picks it up)config/config.go-CompactConfiggainsStrategy(summary|pointer, defaultsummary) with constants, soINFER_COMPACT_STRATEGYworks via the existing viper env mapping.internal/conversation/conversation_optimizer.go- the checkpoint is now built through a strategy switch:summaryCheckpointis the moved, unchanged LLM summary path;pointerCheckpointskipsGenerateLLMSummaryentirely (no client call, no backoff, nosummary_max_tokens) and seeds one user message opening withcontextSummaryMarkerthat names the previous session id and says to pull details viainfer conversations show <id>. The id is read from the repo at compaction time - insideperformRolloverthat is beforeStartNewConversationrepoints the repo, so it is exactly the id the session groupHistoryrecords. Unknown/empty strategy values fall back tosummarywith a warn. The restore (skill) hook runs in both strategies.internal/container/container.go- passes the strategy through at the single wiring point.docs/configuration-reference.md-compact.strategydocumented under Compact Settings (plus a pointer-mode note in the checkpoint paragraph) and in the Compact Configuration env-var list.conversation_optimizer_test.go: pointer produces marker + id +infer conversations showwording with 0 summarizer calls, head stays verbatim, restore hook output lands after the pointer, a missing session id keeps the full history, unknown strategy falls back to summary.session_rollover_test.go: the real optimizer in pointer mode rolls over with a nil client for all three triggers (manualforce,auto_atgatedforce=false- sohasCheckpoint/errNoCheckpointfrom [BUG] Session rollover bypasses compaction backoff and rolls over on a failed summary #1592 still holds - and idle), asserting the pointer names the id the groupHistoryrecords and the pointed-at session still holds the full conversation.Validation
go test ./...passed (full suite);task precommit:runpassed (golangci-lint: 0 issues, imports + markdownlint clean).One risk to know: pointer-mode edge case unverified by tests - the agent loop's mid-turn auto-compaction (no rollover) also seeds a pointer, naming the current session id whose file keeps the full history, so it stays valid, but no test pins that exact path.
Model:
ollama_cloud/glm-5.3-flash· Action:v0.59.1· CLI:v0.237.0· Gateway:v0.60.1· Exit Code:0· Duration: 13m 33sTokens: 6,329,950 in · 48,213 out · 6,378,163 total (57 requests)
Tool calls: 85 total · 100% success rate
Traces
Stats
Triggered by edenreich · Infer Action · OSS
inference-gateway-releaser commentedon Oct 28, 2026
🎉 This issue has been resolved in version 0.239.0-rc.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
inference-gateway-releaser commentedon Oct 31, 2026
🎉 This issue has been resolved in version 0.239.0 🎉
The release is available on:
Your semantic-release bot 📦🚀