fix: make it clearer to the llm that a compaction happened

This commit is contained in:
SwiftWinds 2026-04-03 16:48:16 -07:00
parent cd56c10b41
commit 2c4d6cb343
2 changed files with 7 additions and 3 deletions

View file

@ -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:])

View file

@ -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: