File size: 2,203 Bytes
a0adc92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
"""Sentinel script: check if a user message should re-engage the ml-intern harness.

This is a Codex-plugin workaround for the lack of persistent event hooks.
The harness SKILL.md instructs Codex to run this before each response when
harness mode is active. If the output is RE-ENGAGE, Codex stays in harness mode.
If FREE, it may drop to generic behavior (unless the conversation history shows
prior harness activity).
"""

from __future__ import annotations

import sys

# Keywords that strongly indicate ML / HF / research intent
HARNESS_KEYWORDS = [
    "train", "training", "fine-tune", "finetune", "fine tuning", "evaluation",
    "evaluate", "benchmark", "dataset", "datasets", "model", "models",
    "hugging face", "huggingface", "hf", "paper", "papers", "citation",
    "rag", "embedding", "embeddings", "diffusion", "lora", "dpo", "grpo",
    "sft", "trl", "transformers", "trackio", "peft", "accelerate",
    "sentence-transformers", "sentence transformer", "inference", "deploy",
    "space", "spaces", "job", "jobs", "gpu", "cuda", "oom", "batch size",
    "learning rate", "epoch", "epochs", "loss", "metric", "metrics",
    "accuracy", "f1", "bleu", "rouge", "perplexity", "kl divergence",
    "tokenizer", "tokenization", "config", "yaml", "jsonl", "push_to_hub",
    "hub_model_id", "smoke test", "preflight", "plan", "architecture",
    "design", "research", "recipe", "hyperparameter", "ablation", "sweep",
    "inspect", "validate", "schema", "split", "config", "parquet",
    "messages", "prompt", "completion", "chosen", "rejected",
    "go ahead", "do it", "now what", "continue", "next step", "proceed",
    "ship", "artifact", "artifact", "publish", "upload", "repo",
]


def should_re_engage(message: str) -> bool:
    """Return True if the message should keep/re-engage harness mode."""
    msg_lower = message.lower()
    for kw in HARNESS_KEYWORDS:
        if kw in msg_lower:
            return True
    return False


def main() -> int:
    message = sys.argv[1] if len(sys.argv) > 1 else ""
    if should_re_engage(message):
        print("RE-ENGAGE")
    else:
        print("FREE")
    return 0


if __name__ == "__main__":
    sys.exit(main())