Created
April 4, 2026 17:41
-
-
Save Vaibhavs10/85dec51bbae0cc3bd4179c37c5cea53f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import json | |
| import sys | |
| DONE_MARKER = "__CODEX_DONE__" | |
| payload = json.load(sys.stdin) | |
| msg = (payload.get("last_assistant_message") or "") | |
| # 1) If the model explicitly says it's finished, stop. | |
| if DONE_MARKER in msg: | |
| print(json.dumps({ | |
| "continue": False, | |
| "stopReason": "Task complete" | |
| })) | |
| raise SystemExit(0) | |
| # 2) Safety valve: if this was already auto-continued once, stop. | |
| if payload.get("stop_hook_active"): | |
| print(json.dumps({ | |
| "continue": False, | |
| "stopReason": "Already auto-continued once" | |
| })) | |
| raise SystemExit(0) | |
| # 3) Otherwise continue, but tell the model how to signal completion. | |
| print(json.dumps({ | |
| "decision": "block", | |
| "reason": f"Keep going. When the task is truly complete, end your final message with {DONE_MARKER}." | |
| })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment