Skip to content

toolgate: decide-only endpoint and tool tags - #64

Open
cinar wants to merge 2 commits into
open-experiments:mainfrom
cinar:toolgate-decide-and-tags
Open

cinar wants to merge 2 commits into
open-experiments:mainfrom
cinar:toolgate-decide-and-tags

Conversation

@cinar

@cinar cinar commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Two additions to aex-toolgate that keep its approach: declarative policy, deterministic, fail closed, one record per call. Existing behaviour is unchanged and all existing tests pass.

Decide-only: POST /v1/decide/{tool}

Gate.DecideOnly and POST /v1/decide/{tool} rule on a call and record it, but forward nothing and hold nothing.

  • The artifact's outcome is decided only: not executed by the gate, so the record never reads as an enforced refusal or execution.
  • Only toolcall.requested and toolcall.decided are published.
  • Answers 200 with decision, rule, scope, approval, message, outcome, hash, call_id, plus the usual X-Toolgate-* headers.
  • Operator-only. A gated agent that can ask "would this pass?" without consequence can search the policy for values that slip through.

Use cases: callers that run tools themselves, such as the VetoBench harness (today it points UPSTREAM_URL at a no-op stub), and measuring a policy in shadow before it enforces.

Tool tags

  • tool_tags labels tools with classes, and a rule can name a tag instead of a tool, so one rule governs every tool carrying the tag.

  • New rule kind tool fires on the action itself, whatever the arguments, e.g. {"tag": "destructive", "kind": "tool", "effect": "escalate"}. It takes no arg and must be scoped by a tool or a tag.

  • Argument rules also work by tag, e.g. a ceiling on every money tool. They keep the fail-closed rule for absent arguments.

  • Validation refuses:

    • a tag on a tool missing from tool_scopes;
    • a rule on a tag no tool carries;
    • a rule setting both tool and tag;
    • a tool rule with an arg, or with neither a tool nor a tag.

    Each would otherwise leave a tool silently ungoverned or make a rule fire everywhere.

Motivation: VetoBench's Agent-SafetyBench run spans 1,627 tools. Per-tool rules don't scale, but classes ("destructive", "money", "external send") do.

Tests

  • decide_test.go: the twelve calls through /v1/decide reach the same decisions as /v1/tools, nothing is forwarded, the escalated call leaves no hold, and the chain verifies with 12 records. Without the operator token: 401 and no record.
  • tags_test.go: tag scoping (a tool rule on a tag, a ceiling on a tag, the absent-argument case), each validation error, and a tool rule by name.

A question, not changed here

The Rule comment says an empty tool "applies it to every tool that carries the argument", but evaluate fails closed when the argument is absent. So a rule without a tool denies every tool that lacks the argument: an amount ceiling with no tool denies list_invoices. Safe, but it makes tool-less rules unusable. Should the code or the comment change? Tags cover the use case either way.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ptdu2pZMVdE5x6XkwcUDjj

cinar and others added 2 commits September 30, 2026 12:44
Decide-only: Gate.DecideOnly and POST /v1/decide/{tool} rule on a call and
record it without forwarding or holding it. The artifact's outcome says the
gate did not act, and only toolcall.requested and toolcall.decided are
published. For callers that execute tools themselves (a benchmark harness)
and for measuring a policy in shadow before it enforces. Operator-only: an
agent that can ask what would pass can search the policy for values that
slip through.

Tool tags: tool_tags labels tools with classes, and a rule can name a tag
instead of a tool, so one rule governs every tool carrying it. New rule kind
"tool" fires on the action itself (e.g. every destructive tool escalates);
it takes no arg and needs a tool or a tag. Validation refuses tags on tools
missing from tool_scopes, rules on tags no tool carries, rules setting both
tool and tag, and unscoped tool rules.

Existing behaviour is unchanged; all existing tests pass. New tests: the
twelve calls through /v1/decide (same decisions, nothing forwarded, no hold,
chain verifies), the agent refused at /v1/decide, tag scoping, tag
validation, and a tool rule by name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ptdu2pZMVdE5x6XkwcUDjj
CVE-2026-84445 (HIGH, denial of service via malformed RPC requests) was
published for grpc v1.83.1 after main's last security scan, so Trivy now
fails for every service that links it. v1.83.2 has the fix. It is an
indirect dependency in all fourteen modules that require it; bumping it
raises golang.org/x/net to v0.58.0 and, in five modules, golang.org/x/text
to v0.41.0 and golang.org/x/sys to v0.47.0, the minimums grpc v1.83.2
requires. Every module builds, vets and passes its tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ptdu2pZMVdE5x6XkwcUDjj

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant