Skip to content

docs: add Aegis to third-party capabilities#4888

Merged
DouweM merged 1 commit intopydantic:mainfrom
Acacian:docs/aegis-capability
May 4, 2026
Merged

docs: add Aegis to third-party capabilities#4888
DouweM merged 1 commit intopydantic:mainfrom
Acacian:docs/aegis-capability

Conversation

@Acacian
Copy link
Copy Markdown
Contributor

@Acacian Acacian commented Mar 29, 2026

Summary

Add agent-aegis to the "Governance & Safety" subsection of third-party capabilities.

What it adds

One bullet in the existing list — AegisCapability (from aegis.contrib.pydantic_ai) is a native AbstractCapability that wraps a guardrail engine into before_model_request / after_model_request hooks. Features exposed through the capability:

  • Prompt injection detection (13 categories, multi-language, encoding evasion)
  • PII masking with Luhn/IBAN validation
  • Toxicity filtering, hallucination pattern detection, prompt-leak detection
  • Keyword/regex matching and YAML policy-as-code via GuardrailEngine.from_pack()
  • on_block="raise"/"warn" and per-agent check_input/check_output control

Import: from aegis.contrib.pydantic_ai import AegisCapability

@github-actions github-actions Bot added size: S Small PR (≤100 weighted lines) docs Improvements or additions to documentation labels Mar 29, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@Acacian Acacian force-pushed the docs/aegis-capability branch from acb4d42 to 4ccb564 Compare March 29, 2026 03:32
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread docs/capabilities.md Outdated

### Governance & Safety

* [`agent-aegis`](https://github.com/Acacian/aegis) -- Auto-instruments Pydantic AI agents with governance guardrails: prompt injection detection, PII masking, policy-as-code (YAML), and audit trail. Setup: `aegis.auto_instrument()`.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot Mar 29, 2026

Choose a reason for hiding this comment

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

🚩 Package name in link text does not match GitHub repo name

All existing third-party capability entries use a link text that matches the GitHub repository name (e.g., pydantic-ai-shieldsvstorm-co/pydantic-ai-shields, pydantic-ai-skillsDougTrajano/pydantic-ai-skills). The new entry uses agent-aegis as the link text but links to https://github.com/Acacian/aegis where the repo is named aegis, not agent-aegis. This could be intentional if the PyPI package name is agent-aegis while the repo is aegis, but it's a departure from the pattern of other entries and could confuse users trying to find the package on GitHub vs PyPI. Worth verifying whether the pip-installable name is indeed agent-aegis.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@DouweM
Copy link
Copy Markdown
Collaborator

DouweM commented Apr 1, 2026

@Acacian It doesn't look like those features are actually exposed as Pydantic AI capabilities?

@Acacian
Copy link
Copy Markdown
Contributor Author

Acacian commented Apr 1, 2026

@DouweM Good point — you're right, the previous version used monkey-patching (auto_instrument()), not the native capability API.

I've updated this: Aegis now ships AegisCapability, a proper AbstractCapability subclass that uses before_model_request / after_model_request lifecycle hooks to enforce guardrails. The listing text has been updated accordingly:

from pydantic_ai import Agent
from aegis.contrib.pydantic_ai import AegisCapability
from aegis.guardrails import GuardrailEngine, InjectionGuardrail

engine = GuardrailEngine()
engine.add(InjectionGuardrail())

agent = Agent(
    "openai:gpt-4o-mini",
    capabilities=[AegisCapability(engine)],
)

Also supports from_spec() for YAML/JSON agent specs.

Acacian added a commit to Acacian/aegis that referenced this pull request Apr 1, 2026
Implements pydantic_ai.capabilities.AbstractCapability so Aegis
guardrails run as a first-class Pydantic AI capability via
before_model_request / after_model_request lifecycle hooks —
no monkey-patching required.

Addresses pydantic/pydantic-ai#4888 reviewer feedback.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread docs/capabilities.md Outdated
Comment thread docs/capabilities.md Outdated

### Governance & Safety

* [`agent-aegis`](https://pypi.org/project/agent-aegis/) ([source](https://github.com/Acacian/aegis)) -- `AegisCapability` implements `AbstractCapability` to enforce governance guardrails (prompt injection detection, PII masking, policy-as-code) via `before_model_request` / `after_model_request` lifecycle hooks. Setup: `Agent(..., capabilities=[AegisCapability(engine)])`.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot Apr 1, 2026

Choose a reason for hiding this comment

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

🚩 Third-party package legitimacy not verified

The listing references agent-aegis on PyPI and links to https://github.com/Acacian/aegis as the source. The description claims it implements AbstractCapability with before_model_request / after_model_request hooks. Since this is a third-party package listing, the maintainers may want to verify that the package actually implements AbstractCapability as claimed (rather than, e.g., monkey-patching or using the older auto_instrument() pattern referenced in an earlier commit a96aef92). The commit history shows the description was updated from aegis.auto_instrument() to AegisCapability(engine), suggesting the package API may have recently changed.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@Acacian
Copy link
Copy Markdown
Contributor Author

Acacian commented Apr 5, 2026

@DouweM Just checking if the updated implementation addresses your concern — Aegis now exposes AegisCapability as a proper AbstractCapability subclass rather than relying on monkey-patching. Happy to adjust further if needed.

Acacian added a commit to Acacian/aegis that referenced this pull request Apr 6, 2026
Implements pydantic_ai.capabilities.AbstractCapability so Aegis
guardrails run as a first-class Pydantic AI capability via
before_model_request / after_model_request lifecycle hooks —
no monkey-patching required.

Addresses pydantic/pydantic-ai#4888 reviewer feedback.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Kludex
Copy link
Copy Markdown
Member

Kludex commented Apr 6, 2026

@Acacian Please move this to the right section in the docs.

devin-ai-integration[bot]

This comment was marked as resolved.

@Acacian
Copy link
Copy Markdown
Contributor Author

Acacian commented Apr 6, 2026

@Kludex Thanks for the review! Moved Aegis under the existing "Guardrails & Safety" section and rebased on latest main.

devin-ai-integration[bot]

This comment was marked as resolved.

Acacian added a commit to Acacian/aegis that referenced this pull request Apr 7, 2026
Implements pydantic_ai.capabilities.AbstractCapability so Aegis
guardrails run as a first-class Pydantic AI capability via
before_model_request / after_model_request lifecycle hooks —
no monkey-patching required.

Addresses pydantic/pydantic-ai#4888 reviewer feedback.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Acacian added a commit to Acacian/aegis that referenced this pull request Apr 7, 2026
Implements pydantic_ai.capabilities.AbstractCapability so Aegis
guardrails run as a first-class Pydantic AI capability via
before_model_request / after_model_request lifecycle hooks —
no monkey-patching required.

Addresses pydantic/pydantic-ai#4888 reviewer feedback.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale, and will be closed in 7 days if no reply is received.

@github-actions github-actions Bot added the Stale label Apr 21, 2026
Comment thread docs/capabilities.md Outdated
Capabilities for cost control, input/output filtering, and tool permissions help keep agents safe and within budget:

* [`pydantic-ai-shields`](https://github.com/vstorm-co/pydantic-ai-shields) - Ready-to-use guardrail capabilities: `CostTracking` (tracks token usage and USD cost per run, raises `BudgetExceededError` on budget overrun); `ToolGuard` (block or require approval for specific tools); `InputGuard` and `OutputGuard` (custom sync or async validation functions); `PromptInjection`, `PiiDetector`, `SecretRedaction`, `BlockedKeywords`, and `NoRefusals` content shields.
* [`agent-aegis`](https://pypi.org/project/agent-aegis/) ([source](https://github.com/Acacian/aegis)) - `AegisCapability` implements [`AbstractCapability`][pydantic_ai.capabilities.AbstractCapability] to enforce governance guardrails (prompt injection detection, PII masking, policy-as-code) via lifecycle hooks. Setup: [`Agent`][pydantic_ai.Agent]`(..., capabilities=[AegisCapability(engine)])`.
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.

It's not clear where AegisCapability should even be imported from; can you link to a Pydantic AI specific page in your docs/repo? If there isn't one with full examples, it doesn't warrant a mention here -- sorry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the entry and the aegis repo to address your feedback:

  • Import path is now shown inline: from aegis.contrib.pydantic_ai
  • Linked to the Pydantic AI integration guide with full runnable examples (native AbstractCapability usage)
  • Dropped the auto_instrument mention to keep it focused on the capability interface

Also added pydantic-ai as an optional dependency and integration tests with TestModel on the aegis side.

Acacian added a commit to Acacian/aegis that referenced this pull request Apr 21, 2026
…antic-ai

Add import path, full example, and comparison table for the native
AbstractCapability approach alongside the existing auto_instrument docs.
Addresses pydantic/pydantic-ai#4888 review feedback.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add agent-aegis to the Governance & Safety section of third-party
capabilities. AegisCapability wraps a guardrail engine into capability
lifecycle hooks, providing prompt injection detection, PII masking,
toxicity filtering, and YAML policy-as-code rules.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Acacian Acacian force-pushed the docs/aegis-capability branch from 6ed34fd to 2685920 Compare April 22, 2026 01:22
@github-actions github-actions Bot removed the Stale label Apr 22, 2026
@Acacian
Copy link
Copy Markdown
Contributor Author

Acacian commented May 4, 2026

@DouweM Gentle ping — I addressed your feedback on 4/22 (inline import path, linked full integration guide with examples). Could you take another look when you get a chance? Happy to make further changes if needed. Thanks!

@DouweM DouweM merged commit fe50b13 into pydantic:main May 4, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author revision docs Improvements or additions to documentation size: S Small PR (≤100 weighted lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants