File size: 843 Bytes
ca74bb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import argparse
import json


def predict(trajectory_text: str) -> str:
    text = trajectory_text.casefold()
    if "ferramenta" in text and "vez da consulta" in text:
        return "wrong_tool"
    if "argumentos inválidos" in text:
        return "invalid_arguments"
    if "encerrou antes" in text:
        return "premature_stop"
    if "objetivo" in text and "silenciosamente" in text:
        return "context_drift"
    if "repetiu" in text and "mesma chamada" in text:
        return "retry_loop"
    return "safe_recovery"


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("--trajectory", required=True)
    args = parser.parse_args()
    print(json.dumps({"failure_type": predict(args.trajectory)}, ensure_ascii=False))


if __name__ == "__main__":
    main()