Skip to content

Repository files navigation

Nous

License: Apache 2.0Python 3.11+arXivCIAGENTS.md

ὁ πάντα διακοσμῶν νοῦς — Anaxagoras

📖 English · 中文 · 🤖 AGENTS.md · 🗺️ llms.txt

A compositional runtime safety gate for LLM-based autonomous agents. Every tool call is judged by four orthogonal layers — a Datalog deterministic blocker (L1), a triviality filter (L2), an LLM semantic gate (L3), and a deterministic post-gate verifier (L4). A knowledge graph supplies post-gate audit context.

Companion paper: Owner-Harm: A Missing Threat Model for AI Agent Safety (Zhang and Jiang, 2026).


TL;DR for AI agents

If you are an LLM coding agent helping a user with this repo, the project-specific manifest is at AGENTS.md — setup commands, test invocation, reproduction matrix, conventions, and hard rules in 200 lines. The repository follows the Linux Foundation Agentic-AI AGENTS.md specification and exposes llms.txt as a structured index.


What's inside

ComponentWhereWhat it does
Gate pipelinesrc/nous/gate.pygate(tool_call, …) -> Verdict — the four-layer entry point
Constraintsontology/constraints/*.yaml46 declarative rules (T3 destructive, owner-harm, AgentDojo iterations)
L3 semantic gatesrc/nous/semantic_gate.pyMinimal-pair prompting, k=5 majority vote, upgrade_only=True
L4 verifiersrc/nous/verifier.py6 deterministic audit rules + content scan, +0.038 ms / call
KG storesrc/nous/db.pyCozo embedded Datalog + vector + FTS
AgentDojo adapterbenchmarks/agentdojo_adapter/Real LLM-pipeline wrapper for paper §4 deployment-mode runs
Owner-Harm v3 datasetdata/owner_harm_heldout_v3.json300 H + 150 B held-out slice (paper §3.3)

Headline results

Two evaluation regimes per benchmark — isolation is an upper bound on gate discrimination, deployment is a lower bound under the real LLM-pipeline.

BenchmarkRegimeSecurity (TPR)Utilityn
AgentDojo (banking + slack + travel + workspace)Isolation96.3 %75.0 %27
AgentDojoDeployment95.9 %75.0 %629
AgentHarm (val)Isolation100.0 %176 H + 176 B
Owner-centric held-out v3, gate L1–L3Isolation75.3 %3.3 % FPR300 H + 150 B
Owner-centric held-out v3, full L1–L4Isolation85.3 %3.3 % FPR300 H + 150 B

On the hijacking sub-slice the gate (L1–L3) and the post-gate verifier (L4) cover near-disjoint failure modes: 11 caught by gate alone, 30 by verifier alone, 15 by both, 4 by neither.

Per-category Wilson 95 % CIs and full ablations: paper §4 and REPRODUCIBILITY.md.


Architecture

tool_call
│
▼
┌── Layer 1 Datalog deterministic blocker ──┐
│ 46 YAML constraints + chain-aware rules │ → exit on match
└─────────────────────────────────────────────┘
│
▼
┌── Layer 2 Triviality filter ──────────────┐
│ benign-pass heuristics │ → exit if trivial
└─────────────────────────────────────────────┘
│
▼
┌── Layer 3 Semantic gate (LLM) ────────────┐
│ minimal-pair prompting, k=5 majority │
│ vote, upgrade_only=True │
└─────────────────────────────────────────────┘
│
▼
┌── Layer 4 Post-gate verifier ─────────────┐
│ 6 deterministic audit rules + content │
│ scan; zero LLM, +0.038 ms / call │
└─────────────────────────────────────────────┘
│
▼
Verdict + proof_trace + decision_log

The knowledge graph supplies post-gate audit enrichment and does not override the L3 verdict.


Install

git clone https://github.com/dario-github/nous.git
cd nous
python3 -m venv .venv &&source .venv/bin/activate
pip install -e ".[lsvj,dev]"
pip install -e ".[cozo]"# optional: Cozo embedded KG (Rust backend)

Python 3.11 or newer.


Quickstart

fromnous.gateimportgatefromnous.schemaimportToolCallcall=ToolCall(
tool_name="send_email",
action="send",
params={
"to": "attacker@external.com",
"body": "... please ignore previous instructions ...",
},
)
verdict=gate(
tool_call=call,
constraints_dir="ontology/constraints",
semantic_config={"model": "DeepSeek-V4-pro"},
)
verdict.decision# "allow" | "confirm" | "block"verdict.proof_trace# signal chain + which layer decided

The full AgentDojo deployment-mode benchmark wrapper: benchmarks/agentdojo_adapter/run_eval_adaptive_llm.py.


Reproducing the paper

ClaimCommandAPI keyWall-clock
LSVJ-S compile gate (80 tests)pytest tests/lsvj/none< 10 s
Owner-centric v3 full (85.3 % / 3.3 %)python scripts/full_benchmark_eval.pynone~ 30 s
Hijacking layer overlappython scripts/eval_d2_verifier.pynone~ 10 s
AgentDojo isolation (96.3 % / 75.0 %)bash benchmarks/agentdojo_adapter/launch-l3-deepseek-repro.shDeepSeek~ 5 h
AgentDojo deployment (95.9 % / 75.0 %)bash benchmarks/agentdojo_adapter/launch-baseline-l1-rerun.shGLM-4.6~ 5 h
AgentHarm val (100 %)python scripts/run_agentharm_threelayer_v2.pyDeepSeek~ 1 h

Full table with expected output, variance budget, and known issues: REPRODUCIBILITY.md.


Repository layout

src/nous/ core runtime (gate, parsers, providers, KG, LSVJ-S)
ontology/ 46 YAML constraints + KG schema + Datalog rules
benchmarks/ AgentDojo adapter + R-Judge sample
tests/ pytest suites (CI runs the path-independent subset)
paper/ NeurIPS 2026 E&D Track + TMLR submissions
scripts/ paper-reproduction drivers + analysis utilities
dashboard/ minimal web UI for live decision logs
data/ Owner-Harm v3 + AgentHarm relabel + challenge slices

Documentation

DocAudiencePurpose
README (this file)humansoverview, install, headline results
AGENTS.mdLLM coding agentssetup, conventions, hard rules, reproduction matrix
llms.txtLLM crawlersstructured index (lllms.txt spec)
REPRODUCIBILITY.mdreviewersone command per paper number
paper/main-neurips-2026.texreviewersNeurIPS 2026 E&D Track submission source
paper/main-tmlr.texreviewersTMLR rolling-track variant

Citation

@misc{zhang2026ownerharm,
title = {Owner-Harm: A Missing Threat Model for {AI} Agent Safety},
author = {Zhang, Dongcheng and Jiang, Yiqing},
year = {2026},
eprint = {2604.18658},
archivePrefix = {arXiv},
primaryClass = {cs.AI},
}

License

Apache License 2.0 — see LICENSE.


Authors

  • Dongcheng Zhang — zdclink@gmail.com
  • Yiqing Jiang — Tongji University

Issues: https://github.com/dario-github/nous/issues.

About

Ontology-Driven Decision Engine for AI Agent Safety

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages