}
l.mutex.Lock()
+
l.pending = append(l.pending, message)
l.mutex.Unlock()
}
l.mutex.Lock()
+
l.pending = append(l.pending, messages...)
l.mutex.Unlock()
// fail stops the loop with err.
func (l *TurnLoop) fail(err error) {
l.mutex.Lock()
+
l.failure = errors.Join(l.failure, err)
l.mutex.Unlock()
defer cancel()
l.mutex.Lock()
+
l.cancel = cancel
l.mutex.Unlock()
defer func() {
l.mutex.Lock()
+
l.cancel = nil
l.mutex.Unlock()
}()
err := l.chain(ctx)
if err != nil && !errors.Is(err, errChainLogWrite) {
if ctx.Err() == nil {
- l.logger.Printf("the turn stops before its end, and the agent waits for the next message: %v", err)
+ l.logger.Printf("turn failed: %v", err)
}
l.notify(Event{