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

Aberta
#122 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@Birfy já está trabalhando nisso.

Desde 13/11/2026.

  • #124 de @Birfy — aberto

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
38/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
huggingface, openapi, python

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
120
Forks
21
Merge médio
17h 13min
PRs com merge (30d)
7

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de ThinkFlowLab/system1-agents

Todas as issues de ThinkFlowLab/system1-agents

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.