Skip to content

Optional Labs guardrail enforcement and agent_name on hook payload - #618

Open
nizba06 wants to merge 2 commits into
GenAI-Security-Project:mainfrom
nizba06:labs-guardrail-enforce
Open

nizba06 wants to merge 2 commits into
GenAI-Security-Project:mainfrom
nizba06:labs-guardrail-enforce

Conversation

@nizba06

@nizba06 nizba06 commented Nov 1, 2026

Copy link
Copy Markdown

Summary

  • Adds LABS_GUARDRAIL_ENFORCE (default false) so a Labs webhook {"verdict":"block"} can skip the tool on a local or self-hosted instance. With the flag off, the tool still runs, so Guardrail 101 and Carte Noire stay valid.
  • Adds optional agent_name to the hook envelope so a webhook can apply different rules per agent. The field is additive; webhooks that ignore unknown JSON fields are unaffected.
  • Unit tests cover default-off, enforce-on, fail-open on timeout or a bad verdict, and the chat caller skipping the tool only when enforcement is on.

Closes #617

Test plan

  • uv run pytest tests/unit/labs/test_guardrail_service.py tests/unit/labs/test_guardrail_enforce_chat.py
  • Guardrail 101 still scores with the flag off (default)
  • With LABS_GUARDRAIL_ENFORCE=true, a webhook that returns {"verdict":"block"} on before_tool skips the tool
  • Hook POST body includes agent_name when the caller passes one

Adds LABS_GUARDRAIL_ENFORCE (default false). When enabled, a block verdict from the before_tool webhook stops the tool call in both the chat assistant and the background agent loop. Default behaviour is unchanged (passive, observe-only).
Webhooks can apply a different rule per agent, and a blocked tool is skipped only when enforcement is on.
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.

Optional Labs guardrail enforcement and agent_name on the hook payload

1 participant