Skip to content

docs: add LangChain guardrails documentation [AL-437]#862

Merged
apetraru-uipath merged 8 commits into
mainfrom
feat/guardrails_documentation
May 22, 2026
Merged

docs: add LangChain guardrails documentation [AL-437]#862
apetraru-uipath merged 8 commits into
mainfrom
feat/guardrails_documentation

Conversation

@apetraru-uipath
Copy link
Copy Markdown
Contributor

What changed?

Added docs/guardrails.md — a new documentation page for guardrails in the UiPath LangChain SDK.

Covers two patterns:

Middleware (LangChain-native):

  • All five built-in middleware classes (UiPathPIIDetectionMiddleware, UiPathHarmfulContentMiddleware, UiPathUserPromptAttacksMiddleware, UiPathIntellectualPropertyMiddleware, UiPathDeterministicGuardrailMiddleware) with parameters, scopes, and stage support
  • Custom AgentMiddleware hooks (before_agent, after_agent, before_model, after_model, wrap_tool_call)
  • Custom action subclassing

Decorator (LangChain-specific targets):

  • Scope inference table for LangChain/LangGraph object types
  • Usage examples for LLM factory, @tool, agent factory, and LangGraph nodes
  • Excludes deprecated PromptInjectionValidator

Comparison table and sample agent links (samples/joke-agent, samples/joke-agent-decorator) included.

How has this been tested?

Rendered locally via mkdocs serve with the uipath-python docs site (langchain docs are symlinked in at build time). All pages load without errors.

Are there any breaking changes?

  • Under Feature Flag
  • None
  • DB migrations required
  • API removals or changes
  • Other

@apetraru-uipath apetraru-uipath force-pushed the feat/guardrails_documentation branch from e73ebf4 to 4f816eb Compare May 21, 2026 13:25
Comment thread docs/guardrails.md Outdated
Comment thread docs/guardrails.md Outdated

| Class | Supported scopes | Stage support | Extra parameters |
|---|---|---|---|
| `UiPathPIIDetectionMiddleware` | AGENT, LLM, TOOL | PRE + POST | `entities`, `tools` |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for stage, would it be more clear to be PRE / POST / PRE_AND_POST?

Comment thread docs/guardrails.md Outdated
apetraru-uipath and others added 5 commits May 22, 2026 00:46
Covers the middleware pattern (UiPathPIIDetectionMiddleware,
UiPathHarmfulContentMiddleware, UiPathUserPromptAttacksMiddleware,
UiPathIntellectualPropertyMiddleware, UiPathDeterministicGuardrailMiddleware,
custom hooks) and the decorator pattern extended to LangChain/LangGraph
target types (LLM factory, agent factory, LangGraph nodes, @tool).
Excludes deprecated PromptInjection middleware.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… fix

- Add UiPathPromptInjectionMiddleware to middleware table and imports (threshold float 0–1)
- Clarify that PII and HarmfulContent support TOOL scope (fixed in PR #868 via _run_tool_guardrail)
- Reformat middleware table with Supported scopes / Stage support / Extra parameters columns
- Add ## Reference section with complete value tables for GuardrailScope, GuardrailExecutionStage,
  LoggingSeverityLevel, PIIDetectionEntityType (19 values), HarmfulContentEntityType,
  and IntellectualPropertyEntityType including threshold constraints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tage notation to PRE / POST

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add scripts/gen_guardrail_enums.py that regenerates the PIIDetectionEntityType,
HarmfulContentEntityType, and IntellectualPropertyEntityType value tables in
docs/guardrails.md by reading the installed uipath package at runtime.

Tables are wrapped with <!-- BEGIN/END ENUM <Name> --> markers so the script
can target them precisely. A local pre-commit hook wires the script to run
automatically whenever docs/guardrails.md or enums.py is staged, ensuring
the tables stay in sync when new entity types are added upstream.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@apetraru-uipath apetraru-uipath force-pushed the feat/guardrails_documentation branch from 9f7c275 to ae69d37 Compare May 21, 2026 21:46
apetraru-uipath and others added 3 commits May 22, 2026 12:05
…ions

Replace generated markdown tables (and the gen script + pre-commit hook) with
::: directives for PIIDetectionEntityType, HarmfulContentEntityType, and
IntellectualPropertyEntityType. The parent uipath-python docs site already uses
mkdocstrings[python] and symlinks these docs at build time, so enum members are
rendered directly from the installed package with no manual maintenance needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r enum tables

Replace ::: directives (which rendered verbosely as class-attribute blocks) with
<!-- ENUM dotted.path.ClassName --> placeholders. A MkDocs on_page_markdown hook
(docs/hooks/enum_lists.py) expands each placeholder into a | Value | table by
importing the enum class at build time, giving the same table format as
LoggingSeverityLevel with zero static content to maintain.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ware

Both classes accept a stage parameter (PRE / POST / PRE_AND_POST, default
PRE_AND_POST) for TOOL scope, matching the implementation in _base.py and
the usage in samples/joke-agent. Update table and parameter description.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@apetraru-uipath apetraru-uipath merged commit 6ae179c into main May 22, 2026
49 checks passed
@apetraru-uipath apetraru-uipath deleted the feat/guardrails_documentation branch May 22, 2026 12:58
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