fix:The fix is in place — content = '' is now reset at the start of each loop iteration , which prevents stale text from being duplicated across tool call and end-turn chunks. (#2060)

This commit is contained in:
fdc310
2026-03-21 22:08:35 +08:00
committed by GitHub
parent 9c0cc1003d
commit bd5ec59b7c

View File

@@ -288,10 +288,10 @@ class AnthropicMessages(requester.ProviderAPIRequester):
think_started = False think_started = False
think_ended = False think_ended = False
finish_reason = False finish_reason = False
content = ''
tool_name = '' tool_name = ''
tool_id = '' tool_id = ''
async for chunk in await self.client.messages.create(**args): async for chunk in await self.client.messages.create(**args):
content = ''
tool_call = {'id': None, 'function': {'name': None, 'arguments': None}, 'type': 'function'} tool_call = {'id': None, 'function': {'name': None, 'arguments': None}, 'type': 'function'}
if isinstance( if isinstance(
chunk, anthropic.types.raw_content_block_start_event.RawContentBlockStartEvent chunk, anthropic.types.raw_content_block_start_event.RawContentBlockStartEvent