If nothing has been added to a batch then decoding will fail if attempted. This can happen, for example, if the run loop is woken up but we realize that we have the generation limit.
@@ -184,6 +184,10 @@ func (s *Server) run(ctx context.Context) {
seq.iBatch = batch.NumTokens() - 1
}
+ if batch.NumTokens() == 0 {
+ continue
+ }
+
err := s.lc.Decode(batch)
if err != nil {
slog.Error("failed to decode batch", "error", err)