diff --git a/letta/llm_api/anthropic_client.py b/letta/llm_api/anthropic_client.py index a8c97f97..7861af86 100644 --- a/letta/llm_api/anthropic_client.py +++ b/letta/llm_api/anthropic_client.py @@ -1140,8 +1140,9 @@ def dedupe_tool_results_in_user_messages(messages: List[dict]) -> List[dict]: sep = "\n" if first["content"] and extra else "" first["content"] = f"{first['content']}{sep}{extra}" else: + sep = "\n" if first.get("content") else "" # Fallback: coerce to strings and concat - first["content"] = f"{first.get('content')}{'\n' if first.get('content') else ''}{extra}" + first["content"] = f"{first.get('content')}{sep}{extra}" any_deduped = True dedup_counts[tid] = dedup_counts.get(tid, 0) + 1 # Skip appending duplicate