Upload plugins/ml-intern/skills/ml-intern-harness/scripts/turn_check.py
Browse files
plugins/ml-intern/skills/ml-intern-harness/scripts/turn_check.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Sentinel script: check if a user message should re-engage the ml-intern harness.
|
| 3 |
+
|
| 4 |
+
This is a Codex-plugin workaround for the lack of persistent event hooks.
|
| 5 |
+
The harness SKILL.md instructs Codex to run this before each response when
|
| 6 |
+
harness mode is active. If the output is RE-ENGAGE, Codex stays in harness mode.
|
| 7 |
+
If FREE, it may drop to generic behavior (unless the conversation history shows
|
| 8 |
+
prior harness activity).
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
|
| 13 |
+
import sys
|
| 14 |
+
|
| 15 |
+
# Keywords that strongly indicate ML / HF / research intent
|
| 16 |
+
HARNESS_KEYWORDS = [
|
| 17 |
+
"train", "training", "fine-tune", "finetune", "fine tuning", "evaluation",
|
| 18 |
+
"evaluate", "benchmark", "dataset", "datasets", "model", "models",
|
| 19 |
+
"hugging face", "huggingface", "hf", "paper", "papers", "citation",
|
| 20 |
+
"rag", "embedding", "embeddings", "diffusion", "lora", "dpo", "grpo",
|
| 21 |
+
"sft", "trl", "transformers", "trackio", "peft", "accelerate",
|
| 22 |
+
"sentence-transformers", "sentence transformer", "inference", "deploy",
|
| 23 |
+
"space", "spaces", "job", "jobs", "gpu", "cuda", "oom", "batch size",
|
| 24 |
+
"learning rate", "epoch", "epochs", "loss", "metric", "metrics",
|
| 25 |
+
"accuracy", "f1", "bleu", "rouge", "perplexity", "kl divergence",
|
| 26 |
+
"tokenizer", "tokenization", "config", "yaml", "jsonl", "push_to_hub",
|
| 27 |
+
"hub_model_id", "smoke test", "preflight", "plan", "architecture",
|
| 28 |
+
"design", "research", "recipe", "hyperparameter", "ablation", "sweep",
|
| 29 |
+
"inspect", "validate", "schema", "split", "config", "parquet",
|
| 30 |
+
"messages", "prompt", "completion", "chosen", "rejected",
|
| 31 |
+
"go ahead", "do it", "now what", "continue", "next step", "proceed",
|
| 32 |
+
"ship", "artifact", "artifact", "publish", "upload", "repo",
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def should_re_engage(message: str) -> bool:
|
| 37 |
+
"""Return True if the message should keep/re-engage harness mode."""
|
| 38 |
+
msg_lower = message.lower()
|
| 39 |
+
for kw in HARNESS_KEYWORDS:
|
| 40 |
+
if kw in msg_lower:
|
| 41 |
+
return True
|
| 42 |
+
return False
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def main() -> int:
|
| 46 |
+
message = sys.argv[1] if len(sys.argv) > 1 else ""
|
| 47 |
+
if should_re_engage(message):
|
| 48 |
+
print("RE-ENGAGE")
|
| 49 |
+
else:
|
| 50 |
+
print("FREE")
|
| 51 |
+
return 0
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
sys.exit(main())
|