fix(loop): polling (#2103)

This commit is contained in:
Mauro 2026-03-28 09:36:06 +01:00 committed by GitHub
parent e011284d8f
commit 230942d234
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -387,10 +387,17 @@ func (al *AgentLoop) Run(ctx context.Context) error {
return err return err
} }
for al.running.Load() { idleTicker := time.NewTicker(100 * time.Millisecond)
defer idleTicker.Stop()
for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return nil return nil
case <-idleTicker.C:
if !al.running.Load() {
return nil
}
case msg, ok := <-al.bus.InboundChan(): case msg, ok := <-al.bus.InboundChan():
if !ok { if !ok {
return nil return nil
@ -517,12 +524,8 @@ func (al *AgentLoop) Run(ctx context.Context) error {
al.publishResponseIfNeeded(ctx, target.Channel, target.ChatID, finalResponse) al.publishResponseIfNeeded(ctx, target.Channel, target.ChatID, finalResponse)
} }
}() }()
default:
time.Sleep(time.Microsecond * 200)
} }
} }
return nil
} }
// drainBusToSteering consumes inbound messages and redirects messages from the // drainBusToSteering consumes inbound messages and redirects messages from the