diff --git a/litellm/responses/litellm_completion_transformation/handler.py b/litellm/responses/litellm_completion_transformation/handler.py index f07fb70d97b..63fd09e93a9 100644 --- a/litellm/responses/litellm_completion_transformation/handler.py +++ b/litellm/responses/litellm_completion_transformation/handler.py @@ -169,7 +169,6 @@ def _append_compaction_output( "type": "compaction", "id": "cmp_" + uuid.uuid4().hex, "encrypted_content": encoded_content, - "created_by": None, } if existing_output: return [existing_output[0], compaction_item] + list(existing_output[1:]) diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py index 1b765b6f422..81a79a75557 100644 --- a/litellm/responses/litellm_completion_transformation/transformation.py +++ b/litellm/responses/litellm_completion_transformation/transformation.py @@ -390,8 +390,13 @@ class LiteLLMCompletionResponsesConfig: else: decoded_content = compaction_item.get("content", "") messages.append( - ChatCompletionUserMessage( - role="user", content=decoded_content + ChatCompletionSystemMessage( + role="system", + content=( + "The following is a summary of the prior conversation history, " + "which was compacted to save context space. Treat this as established " + "context, not as a new user message:\n\n" + decoded_content + ), ) ) if last_compaction_idx > 0: