diff --git a/README.md b/README.md index 3656f6c..39cdd6f 100644 --- a/README.md +++ b/README.md @@ -169,8 +169,8 @@ We studied leading coding agents, agent frameworks, and Claw-style assistants to | | **Runtime authoring** | Let an agent author, validate, and load real capabilities at runtime | :white_check_mark: [Docs](pydantic_ai_harness/experimental/authoring/) (experimental) | | | | **Task tracking** | Track tasks, subtasks, and dependencies | :memo: [#65](https://github.com/pydantic/pydantic-ai-harness/issues/65) | [pydantic-ai-todo](https://github.com/vstorm-co/pydantic-ai-todo) (vstorm‑co) | | | **Teams** | Multi-agent teams with shared state and message bus | :memo: [#195](https://github.com/pydantic/pydantic-ai-harness/issues/195) | [pydantic-deep](https://github.com/vstorm-co/pydantic-deepagents) (vstorm‑co) | -| **Safety & guardrails** | **Input guardrails** | Validate user input before the agent run starts | :construction: [PR #182](https://github.com/pydantic/pydantic-ai-harness/pull/182) | [pydantic-ai-shields](https://github.com/vstorm-co/pydantic-ai-shields) (vstorm‑co) | -| | **Output guardrails** | Validate model output after the run completes | :construction: [PR #182](https://github.com/pydantic/pydantic-ai-harness/pull/182) | [pydantic-ai-shields](https://github.com/vstorm-co/pydantic-ai-shields) (vstorm‑co) | +| **Safety & guardrails** | **Input guardrails** | Validate user input before the agent run starts | :white_check_mark: [Docs](pydantic_ai_harness/guardrails/) | [pydantic-ai-shields](https://github.com/vstorm-co/pydantic-ai-shields) (vstorm‑co) | +| | **Output guardrails** | Validate model output after the run completes | :white_check_mark: [Docs](pydantic_ai_harness/guardrails/) | [pydantic-ai-shields](https://github.com/vstorm-co/pydantic-ai-shields) (vstorm‑co) | | | **Cost/token budgets** | Enforce token and cost limits per run | :construction: [PR #182](https://github.com/pydantic/pydantic-ai-harness/pull/182) | [pydantic-ai-shields](https://github.com/vstorm-co/pydantic-ai-shields) (vstorm‑co) | | | **Tool access control** | Block tools or require approval before execution | :construction: [PR #182](https://github.com/pydantic/pydantic-ai-harness/pull/182) | [pydantic-ai-shields](https://github.com/vstorm-co/pydantic-ai-shields) (vstorm‑co) | | | **Async guardrails** | Run validation concurrently with model requests | :construction: [PR #182](https://github.com/pydantic/pydantic-ai-harness/pull/182) | [pydantic-ai-shields](https://github.com/vstorm-co/pydantic-ai-shields) (vstorm‑co) | diff --git a/tests/guardrails/test_output_guard.py b/tests/guardrails/test_output_guard.py index cf4df2a..48318f4 100644 --- a/tests/guardrails/test_output_guard.py +++ b/tests/guardrails/test_output_guard.py @@ -13,6 +13,8 @@ from pydantic import BaseModel from pydantic_ai import Agent from pydantic_ai.capabilities import CapabilityOrdering, Instrumentation from pydantic_ai.exceptions import UnexpectedModelBehavior +from pydantic_ai.messages import ModelMessage, ModelResponse, TextPart +from pydantic_ai.models.function import AgentInfo, FunctionModel from pydantic_ai.models.test import TestModel from pydantic_ai.output import OutputContext from pydantic_ai.tools import RunContext @@ -114,7 +116,10 @@ class TestOutputGuard: return GuardResult.retry('Try again without personal data.') return GuardResult.allow() - agent = Agent(TestModel(custom_output_text='answer'), capabilities=[OutputGuard(guard=guard)]) + def answer(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse: + return ModelResponse(parts=[TextPart('answer')]) + + agent = Agent(FunctionModel(answer), capabilities=[OutputGuard(guard=guard)]) result = await agent.run('hello') assert result.output == 'answer'