Add logging to streaming path in agent-runner
This commit is contained in:
@@ -228,6 +228,8 @@ def handler(event, context):
|
|||||||
continue
|
continue
|
||||||
# Extract text delta from contentBlockDelta
|
# Extract text delta from contentBlockDelta
|
||||||
delta = event.get('event', {}).get('contentBlockDelta', {}).get('delta', {})
|
delta = event.get('event', {}).get('contentBlockDelta', {}).get('delta', {})
|
||||||
|
if not isinstance(delta, dict):
|
||||||
|
continue
|
||||||
token = delta.get('text', '') or event.get('data', '')
|
token = delta.get('text', '') or event.get('data', '')
|
||||||
if token:
|
if token:
|
||||||
text_buffer += token
|
text_buffer += token
|
||||||
@@ -236,11 +238,14 @@ def handler(event, context):
|
|||||||
or len(text_buffer) > 800
|
or len(text_buffer) > 800
|
||||||
)
|
)
|
||||||
if flush and text_buffer.strip():
|
if flush and text_buffer.strip():
|
||||||
|
print(f'[agent-runner] send chunk {len(text_buffer)}c to {chat_id}')
|
||||||
send_telegram_direct(str(chat_id), bot_token, text_buffer.strip())
|
send_telegram_direct(str(chat_id), bot_token, text_buffer.strip())
|
||||||
text_buffer = ''
|
text_buffer = ''
|
||||||
|
|
||||||
# Flush any remaining text
|
# Flush any remaining text
|
||||||
|
print(f'[agent-runner] stream done buffer={len(text_buffer)} bot_token_set={bool(bot_token)}')
|
||||||
if text_buffer.strip() and bot_token:
|
if text_buffer.strip() and bot_token:
|
||||||
|
print(f'[agent-runner] flushing {len(text_buffer)}c to {chat_id}')
|
||||||
send_telegram_direct(str(chat_id), bot_token, text_buffer.strip())
|
send_telegram_direct(str(chat_id), bot_token, text_buffer.strip())
|
||||||
|
|
||||||
print(f"[agent-runner] Completed session={session_id} actor={actor_id}")
|
print(f"[agent-runner] Completed session={session_id} actor={actor_id}")
|
||||||
|
|||||||
Reference in New Issue
Block a user