feat(realtime): configurable pipeline.max_history_items - #10331
Merged
Conversation
Composed realtime pipelines (VAD+STT+LLM+TTS) defaulted to unlimited history, so a long-running session grew every turn and fed the whole conversation to the LLM until its context window filled. Add an optional pipeline.max_history_items to cap the trailing items per turn; explicit value (including 0=unlimited) wins over the per-model-type default. Self-contained any-to-any models keep their 6-item default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Composed realtime pipelines (VAD+STT+LLM+TTS) get
MaxHistoryItems = 0(unlimited) by default — only self-contained any-to-any models (liquid-audio) get the 6-item cap. So a long-running pipeline session grows every turn and feeds the entire conversation to the LLM until its context window fills. There's no way to cap it from config.Fix
Add an optional
pipeline.max_history_itemsto the model config.resolveMaxHistoryItemsuses the explicit value when set (including0= unlimited), otherwise falls back todefaultMaxHistoryItems(6 for realtime-audio, 0 for legacy pipelines). Wired into session init; the existingtrimRealtimeItemsdoes the trimming.Tests cover the resolver (explicit value, explicit 0, fallback-to-default, nil). Existing
defaultMaxHistoryItems/trimRealtimeItemstests unchanged.🤖 Generated with Claude Code