From 00db30c2d116344e815f95a5069bf9c05c5823e6 Mon Sep 17 00:00:00 2001 From: therichardngai-code Date: Tue, 24 Mar 2026 21:14:48 +0700 Subject: [PATCH] fix(agent): set TenantID on streaming events in runLoop emitRun (#445) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The emitRun wrapper in runLoop (loop.go) is missing TenantID, causing all streaming events (chunk, thinking, tool.call) to be emitted with TenantID=Nil. The event filter (event_filter.go:43-44) blocks unscoped events for non-admin clients, so tenant-bound API key users receive no streaming — only run.started and run.completed (emitted from Run() in loop_run.go which already sets TenantID). Fix: add event.TenantID = l.tenantID, matching the pattern in loop_run.go's emitRun wrapper. --- internal/agent/loop.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/agent/loop.go b/internal/agent/loop.go index 83c46ed0..1dd1b13a 100644 --- a/internal/agent/loop.go +++ b/internal/agent/loop.go @@ -37,6 +37,7 @@ func (l *Loop) runLoop(ctx context.Context, req RunRequest) (*RunResult, error) event.UserID = req.UserID event.Channel = req.Channel event.ChatID = req.ChatID + event.TenantID = l.tenantID l.emit(event) }