| """Live check: prewarm + retry reduce fallbacks. Set MODAL_URL/MODAL_TOKEN. |
| Plays several events and reports how many fell back vs. came live (with retry). |
| """ |
| import sys |
| import time |
|
|
| sys.path.insert(0, ".") |
| from game import events, llm, presentation |
| from game.state import GameState |
|
|
| print("pre-warming Modal...") |
| llm.warm() |
| time.sleep(45) |
|
|
| s = GameState(session_id="probe", phase="free_roam") |
| fb_before = 0 |
| for n in range(1, 9): |
| t0 = time.time() |
| ev = events.next_event(s) |
| if ev["kind"] == "presentation": |
| data = presentation.advance(s, "", "") |
| rounds = 0 |
| while data["kind"] == "round": |
| rounds += 1 |
| data = presentation.advance( |
| s, "custom", "We owned it, called the client, and built a real plan.") |
| fb = s.fallback_count - fb_before; fb_before = s.fallback_count |
| print(f"event {n}: PRESENTATION {rounds} rounds, score {data['score']}, " |
| f"fallbacks+{fb} ({int(time.time() - t0)}s)") |
| if data["final"]: |
| break |
| continue |
| fb_arrival = s.fallback_count - fb_before |
| out = events.respond(s, "custom", |
| "Get them on the phone, own it, and offer a real plan.") |
| fb = s.fallback_count - fb_before; fb_before = s.fallback_count |
| print(f"event {n}: {ev.get('special') or 'pitch'} [{ev['arrival']}] " |
| f"-> {out['revenue_delta']:+,} fallbacks+{fb} ({int(time.time() - t0)}s)") |
|
|
| print(f"\nTOTAL fallbacks this run: {s.fallback_count}") |
|
|