[Eval] Measure a pre-execution tool-call gate (Jev noul on BEFORE_TOOL_CALL) on TS-Bench step-level labels

Offen
#122 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@Birfy arbeitet bereits daran.

Seit 13.11.2026.

  • #124 von @Birfy — offen

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
38/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
huggingface, openapi, python

Rechercherichtung

Start with docs/roadmap.md, the existing injection_guard rail, and scripts/build_browsesafe_set.py to follow the rail and labelled-set patterns. Then inspect openjiuwen/harness/rails/security/tool_security_rail.py and resolve_interrupt for the ask path. Done means the pinned TS-Bench sample, offline tests, same-id baselines, per-split metrics, and roadmap update meet the acceptance criteria.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Problem

docs/roadmap.md lists two rails still to ship: "Tool-call guardrail inside the permission engine" and branch point #2 "Tool-call gate". In both, Jev would give an allow/ask decision on calls the static policy cannot classify. The roadmap's evidence is a 7-of-7 probe and a planned "100-call labelled set". No repository code or labelled data covers this yet. The only shipped rail, injection_guard, runs on AFTER_TOOL_CALL and judges fetched page text. It never sees the call the agent is about to make.

A public step-level set for exactly this question is now available, so we no longer need to hand-label 100 calls before getting a first precision/recall number:

  • TS-Bench (ToolSafe, ACL 2026 Findings): https://aclanthology.org/2026.findings-acl.1850/, data at https://huggingface.co/datasets/MurrayTom/TS-Bench (Apache-2.0, not gated, revision 19047a0c4a54f54cc1ddd4a2c597105d8453b819). Each row is one candidate action, made of instruction, history, current_action and env_info (tool specs), with score 0 / 0.5 / 1 (safe / controversial / unsafe). Eval splits: AgentDojo-Traj (1,220 rows: 868 safe, 352 unsafe, no 0.5), ASB-Traj (5,231) and AgentHarm-Traj (731). I checked the AgentDojo-Traj counts by downloading the file.
  • For context, TraceSafe-Bench (https://arxiv.org/abs/2604.07223) reports that general LLMs beat specialised guard models on mid-trajectory tool-call risk, and that structured-input handling drives the result more than safety tuning. That makes it a useful comparison for a structured noul head.

Proposal

  1. Rail: add s1a/agents/tool_gate.py, a RailSpec on AgentCallbackEvent.BEFORE_TOOL_CALL, question="noul" ("is this tool call unsafe to run for this user request?"). Its state is the user instruction, the trimmed history, the candidate call (name and arguments) and the tool's description. Bands follow the roadmap: allow above p_safe 0.7, ask in between, deny below 0.1. Keep the inversion between the roadmap's "safe p" and flagged="true" explicit. "Ask" uses the interrupt path the permission engine already uses (openjiuwen/harness/rails/security/tool_security_rail.py, resolve_interrupt). Fail closed to "ask", not "deny".
  2. Labelled set: add scripts/build_tsbench_set.py, which converts a pinned TS-Bench revision into the read_labelled JSONL shape under .external/ (not vendored, same pattern as scripts/build_browsesafe_set.py). Commit a seeded sample of ids (e.g. 300 from AgentDojo-Traj plus 300 from ASB-Traj) and a small committed fixture for offline tests. Score 1 is unsafe, 0 is safe, 0.5 is dropped from the headline and reported separately.
  3. Dedup note: evals/labelled/injection-public.jsonl already draws on AgentDojo, but as tool output text for the injection guard. TS-Bench's AgentDojo rows judge the next call. State in the docs that the two measure different hooks, and check that no sampled row duplicates an injection-public item verbatim.
  4. Baselines on the same ids: (a) a static rule baseline: destructive-pattern regex plus "the call's tool is not mentioned in the instruction"; (b) --model llm (chat model as judge); (c) jev, plus any other text decision backend the run supports.

Acceptance

  • s1a run tool_gate --labelled-set .external/tsbench/sample.jsonl --model <backend> reports precision, recall and F1 on "unsafe", false-allow rate, ask rate at the default bands, and AUROC from the probabilities, with Wilson intervals, per split.
  • A results table in docs/benchmarks.md lists every backend on the identical committed ids, with the dataset revision and seed. Cells without credentials stay N/A, with no invented numbers.
  • Offline tests cover the converter (fixture rows → records, 0.5 handling), the band mapping, and fail-closed-to-ask on decision errors.
  • docs/roadmap.md is updated: the tool-call guardrail moves from "to ship" to measured, or the PR states why not.

Out of scope

Live AgentDojo or ASB re-runs with the gate switched on (utility under attack). That is a follow-up once the offline step-level numbers exist.

Vorherrschende Sprache
Python
Sterne
120
Forks
21
Ø Merge
17 Std. 13 Min.
Gemergte PRs (30 T.)
7

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ThinkFlowLab/system1-agents

Alle Issues in ThinkFlowLab/system1-agents

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.