Skip to content

feat: Add support for guardrails - #277

Open
milesapnash wants to merge 10 commits into
mainfrom
feat/guardrails
Open

feat: Add support for guardrails#277
milesapnash wants to merge 10 commits into
mainfrom
feat/guardrails

Conversation

@milesapnash

@milesapnash milesapnash commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new guardrails resource type to ADK, supporting both platform (toggle-only) and custom (prompt/action-defined) guardrails, synced through agent_settings/guardrails.yaml.

Motivation

Agent Studio now supports guardrails (platform-provided and custom) that were not yet representable in local ADK projects. This adds first-class support so they can be pulled, edited, and pushed like other resources.

Changes

  • Added PlatformGuardrail and CustomGuardrail resource classes in src/poly/resources/guardrails.py, both stored in agent_settings/guardrails.yaml
  • PlatformGuardrail supports only the enabled toggle against the platform's fixed guardrail catalog (GuardrailName proto enum), with YAML-friendly short names (e.g. jailbreak_defence)
  • CustomGuardrail supports full create/update/delete with name, prompt, action, and enabled fields, plus reference validation against other resource types (global_functions, sms, handoff, attributes, variables, translations)
  • Registered both resource classes via register_resource and exported them from src/poly/resources/__init__.py
  • Added discover_resources/from_projection/to_yaml_dict/from_yaml_dict/validate implementations for both resource types
  • Added guardrails fixture (agent_settings/guardrails.yaml) and updated test_project.json in the test fixture project
  • Added extensive unit tests in src/poly/tests/resources_test.py

Test strategy

  • Added/updated unit tests
  • Manual CLI testing (poly <command>)
  • Tested against a live Agent Studio project
  • N/A (docs, config, or trivial change)

Checklist

  • ruff check . and ruff format --check . pass
  • pytest passes
  • No breaking changes to the poly CLI interface (or migration path documented)
  • Commit messages follow conventional commits

@milesapnash
milesapnash requested review from a team and Ruari-Phipps August 19, 2026 13:14
@linear-code

linear-code Bot commented Aug 19, 2026

Copy link
Copy Markdown

AM-912

DEVP-178

@github-actions

This comment has been minimized.

Comment thread src/poly/resources/guardrails.py
@github-actions

This comment has been minimized.

@milesapnash
milesapnash requested a review from a team as a code owner August 25, 2026 10:52
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

Comment thread docs/docs/reference/resources/guardrails.md Outdated
Comment thread docs/docs/reference/resources/guardrails.md Outdated
Comment thread docs/docs/reference/resources/guardrails.md Outdated
Comment thread docs/docs/reference/resources/guardrails.md
Comment thread docs/docs/reference/resources.md
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Ruari-Phipps Ruari-Phipps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM!

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Base (main) PR Change
75.9% 76.1% +0.2% ✅

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.

2 participants