Skip to content

fix(guardrails): treat both Text and Prompts as the text-only attachment scope - #1112

Open
apetraru-uipath wants to merge 1 commit into
mainfrom
fix/guardrail-applies-to-text
Open

apetraru-uipath wants to merge 1 commit into
mainfrom
fix/guardrail-applies-to-text

Conversation

@apetraru-uipath

@apetraru-uipath apetraru-uipath commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

What changed

_scope_includes_files in src/uipath_langchain/agent/guardrails/attachment_refs.py decides whether a built-in guardrail gets attachment references forwarded with its evaluation, by reading the guardrail's appliesTo parameter.

It was a deny-list: anything that was not the text-only spelling included files. It is now an allow-list of the scopes that include files — {"files", "both"} — so every other present value resolves to text only.

Why an allow-list

The backend is renaming the text-only appliesTo value from Prompts to Text (UiPath/Agents#6385). A deny-list makes the rename itself a regression: a guardrail saved as Prompts stops matching, falls through to "files apply", and starts forwarding the run's files to a validator its author scoped to text.

It also puts the fail-open direction on the widening side. Any value this version does not recognise — an older spelling, or a scope a newer backend introduces — resolved to "files apply". For a guardrail, a value we cannot interpret should narrow, not widen.

The allow-list covers the pre-rename Prompts spelling without naming it as a supported value, and covers whatever comes next.

What is deliberately not changed

An absent parameter still keeps files in scope. Absence carries no author choice to respect, so the backend's per-validator default decides — Both for LLM-as-Judge, which shipped together with file support, Text for the other five. An empty or whitespace-only value is treated as absence for the same reason, matching the backend so both sides agree on which guardrails forward references.

The broad except still keeps files in scope too: the guardrail node re-raises, so a malformed parameter must not end the run, and an unreadable config is closer to absence than to an explicit narrow choice.

The case-insensitive parameter-id match is untouched.

Why Prompts needs no compatibility guarantee

appliesTo has only ever been reachable on alpha. EnableGuardrailAttachments and EnableGuardrailLlmAsJudgeAttachments both have DefaultValue => false and a flag file in the alpha ring only — none of the other eight rings has one — and where file support is off, GuardrailsRegistry.WithoutFileSupportWhenDisabled strips appliesTo from the definitions endpoint, so no designer outside alpha could ever have written the value. There are no customers to stay compatible with; what the value needs is a resolution that does not widen, which this gives it.

Behaviour today

Neutral in every currently reachable configuration. Nothing outside alpha stores appliesTo at all, and helix independently drops references for a text-only guardrail, so no evaluation has ever been mis-judged. What changes is that the runtime stops forwarding references an author scoped out — wasted resolution and payload on every evaluation — and stops treating an uninterpretable scope as permission to read files.

Tests

tests/agent/guardrails/test_attachment_refs.py keeps the shared _SCOPE_CASES list, exercised against both public entry points (resolve_guardrail_attachments and resolve_referenced_attachments):

  • files excluded: "Text", "text", " TEXT ", "Prompts", "prompts", " PROMPTS ", "something-we-never-shipped"
  • files included: "Files", "files", " FILES ", "Both", "both", "", " ", and a guardrail carrying no appliesTo parameter at all

The Prompts rows are the regression guard: not a supported value any more, but it must still resolve to text only rather than to the files-included default.

Gates: pytest tests/agent/guardrails/ 377 passed; ruff check, ruff format --check and mypy clean. Patch version bumped to 0.18.15.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 23, 2026 15:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Updates guardrail attachment scoping to recognize both Text and legacy Prompts values as text-only scopes.

Changes:

  • Added case-insensitive support for both scope values.
  • Expanded tests across both attachment-resolution entry points.
  • Bumped version to 0.18.15.
File Description
uv.lock Synchronizes the locked package version.
tests/​agent/​guardrails/​test_attachment_refs.py Adds comprehensive scope behavior tests.
src/​uipath_langchain/​agent/​guardrails/​attachment_refs.py Handles both text-only scope values.
pyproject.toml Updates the package version.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@apetraru-uipath
apetraru-uipath force-pushed the fix/guardrail-applies-to-text branch from 8a2be51 to cad34af Compare September 23, 2026 21:29
@sonarqubecloud

Copy link
Copy Markdown

The backend renamed the text-only appliesTo value from Prompts to Text. The scope
check here was a deny-list -- anything that was not the text-only spelling included
files -- so the rename alone would have made a guardrail saved as "Prompts" start
forwarding the run's files to a validator its author scoped to text.

Matching a deny-list also puts the fail-open direction on the widening side: any
value this version does not recognise resolves to "files apply".

Match an allow-list of the scopes that include files instead. Only Files and Both
forward references; every other present value resolves to text only. That covers
the pre-rename Prompts spelling without naming it as a supported value, and covers
any scope a newer backend introduces.

An absent parameter is deliberately left alone: it carries no choice to respect, so
the backend's per-validator default still decides. An empty or whitespace-only value
is treated as absent, matching the backend, so both sides agree on which guardrails
forward references.

appliesTo has only ever been offered on alpha -- EnableGuardrailAttachments and
EnableGuardrailLlmAsJudgeAttachments both default to false and have a flag file in
the alpha ring only, and the definitions endpoint strips the parameter wherever file
support is off -- so Prompts needs no compatibility guarantee, only a non-widening
resolution.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@apetraru-uipath
apetraru-uipath force-pushed the fix/guardrail-applies-to-text branch from cad34af to 1dad60b Compare September 24, 2026 07:52

This branch has not been deployed

No deployments
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