They list a private berth for 808 PLN and a triple compartment for 460 PLN.
Well, it's definitely too much and honestly it can be called "greediness". At the moment official fare for 1st class one-way ticket is 121 EUR + 49 EUR for a single sleeper reservation, thus it makes it around 700 PLN in total. So everything above it goes into agencies pockets. Also you should know that there is a discounted SparNight tickets available for Krakow-Budapest carriages, for single sleeper it costs 99 EUR (ticket+reservation) and anyone (including agency) having access to Polish system or ticket desk can purchase it, so it's not necessarily about 170 EUR, but can be about 99 EUR in case you (or someone for you) 'catches' discounted tickets while they still available. Our guess is that time to time agencies can even profit by selling discounted SparNight ticket for standard fare (makes it more profitable for them), thus tricking customers even more.
Regarding 3 bed compartment, 2nd class ticket cost 80,6 EUR + 14 EUR sleeper reservation, thus it makes it app.395 PLN in total, that's what you'll pay at the station. Double: same 80,6 EUR for 2nd class ticket + 21 EUR for sleeper reservation
Would I be able to get a cheaper rate for a bed in a triple compartment if I buy at the Krakow train station 2 days before my departure?
Above we gave you official fares, so guess it won't be a problem to count the difference between real fare and the agency
... and I think the triple comes with coffee and some kind of breakfast in the morning.
Actually they even have pictures of the so-called 'breakfast', you can see it
here, second page it's double and triple, while third page - single.
So the question then is, is it worth the 33 PLN extra to get a double rather than a triple?
Basically difference is 7 EUR, while compartment is the same (obviously besides -1 potential passenger in it). Thus the choice is yours, whether it worth it or not, 1 vs.2 potential 'roommates'. As a rule, those few carriages from Krakow to Budapest are quite popular during high-season, but still it doesn't necessarily guarantee you any company.
Is it possible for me to buy the Krakow-Budapest ticket while in Berlin prior to my May 28th arrive to Krakow?
Your actual concern is sleeper reservation, while ticket in this case is secondary, so you can buy it any time without any limitations. It's sleeper reservation that might be sold out and then there is a problem.
Regarding Berlin: good chances that reservations Krakow-Budapest are in EPA (German reservation system), and if is so, then it will be really easy to purchase such reservation in advance in Berlin (you don't need to have ticket for purchasing reservation), while ticket you can buy already in Poland.