Compare commits

...

1 Commits

Author SHA1 Message Date
willy-scr
0f1a53382e fix(gateway): use source.thread_id instead of undefined event in queued response
In _run_agent(), the pending message handler references 'event' which
is not defined in that scope — it only exists in the caller. This
causes a NameError when sending the first response before processing a
queued follow-up message.

Replace getattr(event, 'metadata', None) with the established pattern
using source.thread_id, consistent with lines 2625, 2810, 3678, 4410, 4566
in the same file.
2026-04-11 14:22:37 -07:00

View File

@@ -8131,7 +8131,7 @@ class GatewayRunner:
if first_response and not _already_streamed: if first_response and not _already_streamed:
try: try:
await adapter.send(source.chat_id, first_response, await adapter.send(source.chat_id, first_response,
metadata=getattr(event, "metadata", None)) metadata={"thread_id": source.thread_id} if source.thread_id else None)
except Exception as e: except Exception as e:
logger.warning("Failed to send first response before queued message: %s", e) logger.warning("Failed to send first response before queued message: %s", e)
# else: interrupted — discard the interrupted response ("Operation # else: interrupted — discard the interrupted response ("Operation