Welcome to Tropical Fish Keeping forum. Nice to have you with us.
Most species of pencilfish are very sensitive to water conditions and parameters. The most common species, Nannostomus beckfordi
, is the hardiest and can almost survive anything. But all the others are quite the opposite. We have fish profiles, under the second tab from the left in the blue bar across the top. If the common or scientific name is used in a post exactly as it appears in the profile, it will shade, as it did earlier, and you can click on it for that profile. Have a look at the profiles, pencilfish are under the characins group, and track down your particular species. That will tell you about their preferred (= necessary with these fish) water parameters.
When you say there is no issue with pH or ammonia, what are the numbers? With these fish, pH is critical, and any ammonia can be fatal. While fish may seem to survive initially, ammonia poisoning along with nitrite poisoning will take its toll and early death is almost always the result. So we should explore that.
Also, pencilfish are shoaling fish and always do best in groups. As mentioned in the profiles, six is minimum but more is better. Being alone, or in a group of 2 or 3 of the species is highly stressful for shoaling fish. And this only adds to the other stress factors.
All of the above individually or collectively may explain the demise of the pencils. You have another issue though, and that concerns the two cichlids. A 30g is suitable for a pair of Apistogramma nijsseni (I assume this is the species of the "panda" cichlid) or in this species a male with 2 or 3 females works fine (called a harem). I would not however have Bolivian Rams [Mikrogeophagus altispinosus
] in the same tank, a 30g is not sufficient space for both. All cichlids are territorial, especially when spawning, but the male rules the tank and while it may only show as mild chasing or nudging, this also is highly stressful long-term. If the Bolivians are a male/female pair, they can manage in a 30g without other cichlids; if they are both males, one will be dead before long. You can read more in our profile.