← Lesson
Stop Rules
Joeven
Run
Reset
Python loads on first run
def goal_satisfied(world): return world.get("status") in {"failed", "ok"} and "error" in world def after_model(action, world, step, max_steps): if step >= max_steps: return "STOP: budget" if action["tool"] == "finish": if goal_satisfied(world): return "SUCCESS: " + action["args"]["answer"] return "REJECT finish: world not done" if action["tool"] == "handoff": return "HANDOFF: " + action["args"]["reason"] return "CONTINUE" world = {"status": "unknown"} print(after_model({"tool": "finish", "args": {"answer": "all good"}}, world, 1, 4)) world = {"status": "failed", "error": "timeout"} print(after_model({"tool": "finish", "args": {"answer": "Job 17 failed: timeout"}}, world, 2, 4)) print(after_model({"tool": "get_job", "args": {}}, world, 4, 4)) print(after_model({"tool": "handoff", "args": {"reason": "need a human"}}, world, 2, 4))
Run to execute this in your browser. Nothing is sent to a server.