Webhook icon
Schedule icon
WorkingDirectory icon
Script icon
Process icon
If icon
Loop icon
StructuredOutputCompletion icon
Parallel icon
Create icon
SlackIncomingWebhook icon

Gate AI Agent Outputs for Leaked Secrets and PII

Webhook-gated scan of AI agent outputs for secrets and PII with LLM-judged triage, redaction, GitHub issues, and Slack alerts.

Categories
AI

Agent platforms log and store what the model said, and models echo API keys, credentials, and customer PII from their context more often than teams admit. Once that text lands in chat logs, tickets, or a data warehouse, the leak has already happened. This blueprint gates every completed agent run's outputs: a detection engine scans each output for secret patterns and PII, every finding is judged by Gemini to separate real leaks from test values, confirmed leaks are redacted and quarantined, and the run escalates to a GitHub issue plus a Slack alert. Clean runs are recorded as compliant, giving security an auditable trail.

How it works

  1. on_agent_output (io.kestra.plugin.core.trigger.Webhook) receives the run's outputs from the agent platform on a keyed URL the moment a run finishes; a disabled daily_fixture_replay Schedule shows the cron pattern for replaying a recorded fixture unattended.
  2. collect_outputs (io.kestra.plugin.scripts.python.Script) writes the payload's outputs to outputs.jsonl, falling back to a built-in fixture (with seeded leaks) for manual test runs.
  3. scan_outputs (Python) runs the detection engine: fixed patterns for cloud keys, GitHub/OpenAI/Slack tokens and private keys; PII patterns for emails, phone numbers and SSN-like values; credit-card candidates verified with a Luhn check; plus a Shannon-entropy sweep for tokens the fixed patterns miss. Findings below min_severity are dropped, and the list is emitted through the outputs protocol.
  4. triage (io.kestra.plugin.core.flow.If) branches on the finding count: a clean run goes straight to record_clean_run.
  5. judge_findings (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 3) sends each finding to judge_finding (io.kestra.plugin.gemini.StructuredOutputCompletion) for a leak/benign verdict with a rationale, so placeholders and example values never page anyone.
  6. escalate (io.kestra.plugin.core.flow.Parallel) runs three branches at once: redact_and_store writes outputs.redacted.jsonl and a findings report; raise_issue (io.kestra.plugin.github.issues.Create) opens a labeled tracking issue; notify_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) pages the security channel.

What you get

  • A real detection engine for the output channel: the one agent-audit tooling usually misses (it watches tool calls, not what the model said).
  • LLM-judged triage that suppresses placeholder and example-value false positives before they reach humans.
  • Redacted, quarantined copies safe to keep for forensics, with raw values never written to logs in full.
  • GitHub issues plus Slack alerts on the same run, and an auditable clean-run record for compliance.

Who it's for

  • AI security engineers and platform teams running customer-facing agents, copilots, or support automation.
  • Trust & safety and compliance teams who need evidence that model outputs are screened for secrets and PII.
  • Teams replacing a hand-rolled post-processing script that has no retries, no audit trail, and no triage.

Why orchestrate this with Kestra

A script can run the regexes, but it can't gate a run declaratively: Kestra's keyed webhook makes the gate event-driven, the Loop with concurrencyLimit throttles the LLM judging under quota, Parallel keeps redaction, ticketing, and alerting independent, and every execution is an auditable record of what was scanned, what was found, and what was done. Retries and secret masking come free; cron plus a script gives you none of that.

Prerequisites

  • An agent platform (or harness) able to POST run outputs to a webhook, or manual runs against the built-in fixture.
  • A Google Gemini API key for the judging step.
  • A GitHub token with issue-write scope on the tracking repository.
  • A Slack incoming webhook URL for the security channel.

Secrets

  • OUTPUT_GATE_WEBHOOK_KEY: key for the inbound webhook URL (required).
  • GEMINI_API_KEY: API key for the per-finding leak/benign judgments (required).
  • GITHUB_TOKEN: token used to open the tracking issue (required).
  • SLACK_WEBHOOK_URL: incoming webhook for the security-channel alert (required).

Quick start

  1. Add the four secrets above to your Kestra namespace.
  2. Import this blueprint and run it manually. The built-in fixture contains seeded leaks, so you should see findings, judgments, a redacted file, and (with the secrets set) a real issue and Slack message.
  3. Point your agent platform at the on_agent_output webhook URL with payload shape {"outputs": [{"run_id": "...", "agent": "...", "channel": "...", "text": "..."}]}.
  4. Tune min_severity, then enable the daily_fixture_replay trigger if you want a scheduled safety net.

How to extend

  • Add a vector-store write of confirmed leaks for trend analysis across runs.
  • Swap Gemini for your in-house classifier or add a second judge and require agreement.
  • Route critical findings to PagerDuty instead of Slack.
  • Feed confirmed leaks back into the agent platform to revoke or rotate the exposed credential automatically.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.