From e38647151db31e0333b503968caeb584827fea93 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Sat, 11 Apr 2026 14:39:25 -0400 Subject: [PATCH] Fix language: binary data is replaced with placeholders, not truncated --- changelog/4272.added.md | 2 +- src/pipecat/processors/aggregators/llm_context.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog/4272.added.md b/changelog/4272.added.md index af278e770..69bfcf8bb 100644 --- a/changelog/4272.added.md +++ b/changelog/4272.added.md @@ -1 +1 @@ -- Added `truncate_large_values` parameter to `LLMContext.get_messages()`. When `True`, returns compact deep copies of messages with binary data (base64 images, audio) fully truncated and long string values in LLM-specific messages recursively truncated. Useful for serialization, logging, and debugging tools. +- Added `truncate_large_values` parameter to `LLMContext.get_messages()`. When `True`, returns compact deep copies of messages with binary data (base64 images, audio) replaced by short placeholders and long string values in LLM-specific messages recursively truncated. Useful for serialization, logging, and debugging tools. diff --git a/src/pipecat/processors/aggregators/llm_context.py b/src/pipecat/processors/aggregators/llm_context.py index 00ec8f178..7bcb68c86 100644 --- a/src/pipecat/processors/aggregators/llm_context.py +++ b/src/pipecat/processors/aggregators/llm_context.py @@ -214,9 +214,9 @@ class LLMContext: logged; this is intended to catch accidental use of incompatible LLM-specific messages. truncate_large_values: If True, return deep copies of messages with - large values replaced by short placeholders. For standard - messages, known binary data (base64-encoded images, audio) is - fully truncated. For LLM-specific messages, long string values + large values shortened. For standard messages, known binary + data (base64-encoded images, audio) is replaced with short + placeholders. For LLM-specific messages, long string values are truncated. Returns: @@ -247,7 +247,7 @@ class LLMContext: """Return deep copies of messages with large values replaced by placeholders. For standard (universal-format) messages, the following known binary - patterns are fully truncated: + patterns are replaced with short placeholders: - ``image_url`` items with ``data:image/...`` base64 URLs - ``input_audio`` items with ``input_audio.data`` or ``audio`` fields