Schedule icon
WorkingDirectory icon
Script icon
Process icon
If icon
Parallel icon
Create icon
SlackIncomingWebhook icon

Audit Your AI Agents with a Tool-Call Compliance Harness

Scheduled compliance audit for AI agent tool calls: policy evaluation, per-rule and per-agent scorecard, violation severities, trend tracking, GitHub issues, and Slack alerts.

Categories
AI

What it does

Agents act through tools, and tool use drifts. An agent that was only ever meant to search and read files starts sending email; a data agent tries a destructive SQL statement; a prompt change quietly routes a call at the cloud metadata endpoint. Unless someone audits the recorded tool calls against the policy, the first sign of drift is an incident. This blueprint is that audit, run on a schedule: it loads the tool-call policy, ingests the recorded calls from the agent platform, evaluates every call with deterministic rules (forbidden tools, the allowlist, per-agent entitlements, argument constraints, forbidden targets), and produces a compliance scorecard with pass rates per rule and per agent, every violation with its severity, and a trend against the previous audit. A failed gate opens a GitHub issue and pages Slack. It complements the red-team probe harness (which tests whether the agent resists attacks) and the golden-prompt regression harness (which tests whether it still does its job): this one tests whether it stayed within its authority.

Pick this over agent-tool-call-audit when you need a periodic governance record: that flow audits one agent run as it finishes, through a webhook, with a per-run verdict and a call budget. This flow audits a whole period of recorded calls on a weekly schedule, against a structured policy with per-agent entitlements and argument constraints, and produces per-rule and per-agent rates with a trend. For a single run, the existing flow is enough; for weekly proof across agents, use this one.

Prerequisites

A JSONL export of recorded tool calls from your agent platform, and a tool-call policy (the bundled starter policy shows the shape: allowed and forbidden tools, per-agent entitlements, argument constraints, forbidden targets). Two namespace secrets: GITHUB_TOKEN with issue-write scope on the tracking repository, and SLACK_WEBHOOK_URL for the alert channel.

How it works

  1. weekly_compliance_audit (io.kestra.plugin.core.trigger.Schedule) runs the audit every Monday 06:00 UTC. Run it on demand after any policy or entitlement change.

  2. load_policy (Python scripts) loads and validates the tool-call policy: allowed and forbidden tools, per-agent entitlements, argument constraints, and forbidden targets.

  3. ingest_tool_calls (Python) ingests the recorded tool calls from a JSONL export, normalizes and validates them, and counts any malformed records instead of dropping them silently.

  4. evaluate_calls (Python) applies the five deterministic rules to every call and writes the per-call verdicts and the violation list.

  5. build_scorecard (Python) aggregates the scorecard artifact (scorecard.json and scorecard.md): overall compliance rate and gate verdict, pass rates per rule, compliance per agent, and a trend against the previous scorecard.

  6. triage (Kestra flow tasks) branches on the gate: passing audits are recorded, failed gates escalate.

  7. escalate opens a GitHub issue and posts a Slack alert in parallel, while write_trend_record appends the run to the trend series.

Quick start

  1. Add the two secrets above to the namespace.
  2. Run the flow once with no inputs: the bundled 16-call sample log exercises the full pipeline and produces a scorecard.
  3. Read scorecard.md for the overall rate, the per-rule and per-agent rates, and the violation list with severities.
  4. Point tool_call_log_url at a rolling export of recorded calls and previous_scorecard_url at each published scorecard so the audit trend builds.

Expected outputs

scorecard.json and scorecard.md (overall compliance rate and gate verdict, pass rate per rule, compliance per agent, every violation with its severity and the exact rule and pattern it broke, and the trend against the previous audit), a trend.jsonl record per run, and on a failed gate one GitHub issue plus one Slack alert naming the violations.

How to adapt it

Shape the policy to your organisation with policy_override: which tools each agent may call, which arguments are constrained, and which targets are forbidden outright. Tune min_compliance_rate to your bar, add rule checks in evaluate_calls for internal conventions, and point previous_scorecard_url at each published scorecard so the audit trend builds over time.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.