zylon-ai/private-gpt · error · ValueError
System messages alone exceed the maximum length. Cannot cond
Error message
System messages alone exceed the maximum length. Cannot condense conversation history.
What it means
Raised in the TLDR condensation pipeline before any condensing happens: the token count of the system messages alone is >= max_length, leaving zero (or negative) budget for the conversation. Because system messages are always preserved, condensation cannot proceed and the processor aborts with this ValueError.
Source
Thrown at private_gpt/components/chat/processors/chat_history/memory/tldr_processor.py:84
trim_to_last_tldr, conversation_history
)
# 2. Check if condensation is needed
if not chat_history or not max_length:
yield CondenseResponse(chat_history=chat_history, condense_blocks=None)
return
# 2. Ensure that max_length - system_messages_length is greater than 0
remaining_max_length = max_length
if system_messages:
system_token_count = await estimate_token_count(
system_messages,
tokenizer_fn=tokenizer_fn,
message_to_input=message_to_input,
**kwargs,
)
if system_token_count >= max_length:
raise ValueError(
"System messages alone exceed the maximum length. Cannot condense conversation history."
)
remaining_max_length -= system_token_count
if condense_strategy is None:
strategy_type = CondenseStrategyType.from_string(str(strategy_type))
if strategy_type == CondenseStrategyType.UNKNOWN:
yield CondenseResponse(chat_history=chat_history, condense_blocks=None)
return
if str(strategy_type) in CACHE_CONDENSE_STRATEGY:
condense_strategy = CACHE_CONDENSE_STRATEGY[str(strategy_type)]
else:
condense_strategy = get_condense_memory_strategy(
strategy_type,
injector=injector,
message_to_input=message_to_input,View on GitHub (pinned to 4a030776a3)
Solutions
- Increase max_length (raise the condensation budget setting)
- Reduce the system prompt size — trim instructions, remove injected context
- Check tokenizer_fn matches the target model so the count is accurate
- Fail fast at startup with a config validation asserting system_tokens < max_length
Example fix
# before settings.condenser.max_length = 1024 # system prompt is ~1500 tokens # after settings.condenser.max_length = 8192 # comfortably above system prompt size
Defensive patterns
Strategy: validation
Validate before calling
sys_tokens = await estimate_token_count(system_messages, tokenizer_fn=tokenizer_fn)
if sys_tokens >= max_length:
raise ConfigError("system prompt too large for condensation budget") Try / catch
try:
async for resp in run_tldr_condense(chat_history, max_length=ml, system_messages=sys_msgs):
...
except ValueError as e:
if "System messages alone exceed" in str(e):
ml = sys_tokens + fallback_conversation_budget # or abort with a clear message
else:
raise Prevention
- Track system-prompt token count in CI as a guarded metric
- Never let retrieved context land in the system message without a size cap
- Document a minimum max_length per model in deployment settings
When it happens
Trigger: Calling the tldr condense flow with a system prompt whose estimated token count >= max_length; estimate_token_count(system_messages, ...) returning a value >= the configured max_length.
Common situations: RAG/system prompts stuffed with retrieved context or long instructions combined with a small max_length; changing to a model with a smaller context window without retuning condensation settings; tokenizer_fn that overestimates tokens.
Related errors
- Condensed chat history exceeds maximum length after applying
- Condensed history exceeds maximum length after applying cond
- No user messages found in the chat history.
- Maximum number of iterations for condensing exceeded.
- The last user message exceeds the maximum length allowed.
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/529a598b46f3057c.
Report an issue: GitHub.