From e4f35a2d8b24c21db7733396639036072e09f512 Mon Sep 17 00:00:00 2001 From: KoalaTrapLord <265133236+KoalaTrapLord@users.noreply.github.com> Date: Fri, 3 Apr 2026 16:08:50 -0400 Subject: [PATCH] debug: log top-5 action probabilities on every decide() call Adds a single INFO log line after each successful inference showing: - chosen action + confidence - top-5 actions sorted by probability - turn, phase, vector_source This lets us diagnose the 'only plays lands' behaviour without a Python REPL. Remove or downgrade to DEBUG once the training issue is resolved. --- routes/policy.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/routes/policy.py b/routes/policy.py index 32e2d65..2af9f3d 100644 --- a/routes/policy.py +++ b/routes/policy.py @@ -342,6 +342,24 @@ async def decide(req: DecideRequest): if "error" in result: raise HTTPException(500, detail=result["error"]) + # ---------------------------------------------------------------- + # Probability diagnostic — logs top-5 actions on every decision. + # Remove or downgrade to logger.debug once training looks healthy. + # ---------------------------------------------------------------- + probs = result.get("probabilities", {}) + if probs: + top5 = sorted(probs.items(), key=lambda kv: kv[1], reverse=True)[:5] + top5_str = ", ".join(f"{a}:{p:.3f}" for a, p in top5) + logger.info( + "[decide] turn=%d phase=%s → %s (conf=%.3f) | top5=[%s] | src=%s", + req.resolved_turn(), + req.phase, + result["action"], + result["confidence"], + top5_str, + vector_source, + ) + log_prob = 0.0 try: conf = result.get("confidence", 0.5)