From fb092d7fa9252216d4cef43f8bb27e7f2ea7cbe6 Mon Sep 17 00:00:00 2001 From: Will Sargent Date: Mon, 10 Mar 2025 17:20:49 -0700 Subject: [PATCH] fix: Spurious empty chunk warning on Claude (#2476) --- letta/server/rest_api/interface.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/letta/server/rest_api/interface.py b/letta/server/rest_api/interface.py index 102835d0..d728f60d 100644 --- a/letta/server/rest_api/interface.py +++ b/letta/server/rest_api/interface.py @@ -918,13 +918,15 @@ class StreamingServerInterface(AgentChunkStreamingInterface): # skip if there's a finish return None else: - # Example case that would trigger here: - # id='chatcmpl-AKtUvREgRRvgTW6n8ZafiKuV0mxhQ' - # choices=[ChunkChoice(finish_reason=None, index=0, delta=MessageDelta(content=None, tool_calls=None, function_call=None), logprobs=None)] - # created=datetime.datetime(2024, 10, 21, 20, 40, 57, tzinfo=TzInfo(UTC)) - # model='gpt-4o-mini-2024-07-18' - # object='chat.completion.chunk' - warnings.warn(f"Couldn't find delta in chunk: {chunk}") + # Only warn for non-Claude models since Claude commonly has empty first chunks + if not chunk.model.startswith("claude-"): + # Example case that would trigger here: + # id='chatcmpl-AKtUvREgRRvgTW6n8ZafiKuV0mxhQ' + # choices=[ChunkChoice(finish_reason=None, index=0, delta=MessageDelta(content=None, tool_calls=None, function_call=None), logprobs=None)] + # created=datetime.datetime(2024, 10, 21, 20, 40, 57, tzinfo=TzInfo(UTC)) + # model='gpt-4o-mini-2024-07-18' + # object='chat.completion.chunk' + warnings.warn(f"Couldn't find delta in chunk: {chunk}") return None return processed_chunk