tkhersoft's picture
temp build/analysis scripts (54 py files) backup before prune
94da461 verified
Raw
History Blame Contribute Delete
1.31 kB
"""Print the next N caught rows not yet in out/done_ids.txt, with everything
needed to author a bespoke remediation proposal. Usage:
python temp/story_remediation/next_batch.py [N]
"""
import json, sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
OUT = HERE / "out"
N = int(sys.argv[1]) if len(sys.argv) > 1 else 20
done = set()
p = OUT / "done_ids.txt"
if p.exists():
done = {l.strip() for l in p.read_text(encoding="utf-8").splitlines() if l.strip()}
rows = [json.loads(l) for l in (OUT / "caught_rows.jsonl").read_text(encoding="utf-8").splitlines() if l.strip()]
pending = [r for r in rows if r["item_id"] not in done]
print(f"# done={len(done)} pending={len(pending)} showing next {min(N,len(pending))}")
for r in pending[:N]:
print("=" * 100)
print(f'{r["item_id"]} | tool={r["tool"]} | conf={r["confidence"]} | tells={r["tells"]} | n_calls={r["n_calls"]} | n_hist={r["n_hist_turns"]}')
print("QUERY:", r["query"])
print("REASON:", r["reasoning"])
# show the history dialogue so re-staging fits the existing flow
for h in r["history"]:
tc = f" [+{h['n_tool_calls']} tool_calls]" if h["n_tool_calls"] else ""
c = h["content"][:220] if h["content"] else ""
print(f' ({h["role"]}){tc}: {c}')