Remove mid-stream flush on newlines: prevents split multi-turn responses
This commit is contained in:
@@ -245,11 +245,8 @@ def handler(event, context):
|
||||
token = delta.get('text', '')
|
||||
if token:
|
||||
text_buffer += token
|
||||
flush = (
|
||||
text_buffer.rstrip().endswith(('\n\n', '.\n', '!\n', '?\n'))
|
||||
or len(text_buffer) > 800
|
||||
)
|
||||
if flush and text_buffer.strip():
|
||||
# Only flush if buffer is very large — prevents splitting multi-turn responses
|
||||
if len(text_buffer) > 1200:
|
||||
print(f'[agent-runner] send chunk {len(text_buffer)}c to {chat_id}')
|
||||
send_telegram_direct(str(chat_id), bot_token, text_buffer.strip())
|
||||
text_buffer = ''
|
||||
|
||||
Reference in New Issue
Block a user