Skip to content

feat: allow guardrail evaluation to carry attachment references - #1895

Open
apetraru-uipath wants to merge 4 commits into
mainfrom
feat/guardrail-judge-file-support
Open

apetraru-uipath wants to merge 4 commits into
mainfrom
feat/guardrail-judge-file-support

Conversation

@apetraru-uipath

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

Copy link
Copy Markdown
Contributor

What

Adds an optional attachments keyword to GuardrailsService.evaluate_guardrail and a GuardrailAttachment model (id, fileName, mimeType, url), so a caller can tell the guardrails backend which files a guardrail should inspect — rather than the backend seeing only attachment metadata embedded in the payload string.

Bumps uipath-platform to 0.2.29.

Review fixes

  • e831652c — SAS urls no longer reach the trace span. @traced records a function's arguments on the OpenTelemetry span by default, so every GuardrailAttachment.url (a short-lived SAS credential) was landing in input.value. An input_processor now redacts attachments[*].url and leaves the rest of the span intact — tighter than hide_input=True. Thanks Copilot.
  • 49b50329 — lockfiles relocked after the version bump (uv lock --check in CI).
  • Added the two tests Copilot noted were missing: an attachment-bearing evaluation forwards the 60 s timeout; the default path does not.

Notes for reviewers

  • Backward compatible. Without attachments, or with an empty list, the request body is byte-identical to today.
  • Timeout. A validate call carrying attachments waits for the backend to fetch and decode each file. The default client timeout is 30 s and RequestSpec.timeout was constructed but never forwarded, so this passes 60 s explicitly when attachments are present.

Test plan

packages/uipath-platform35 tests pass (+8 over baseline). ruff check, ruff format --check, mypy src tests clean.

Pairs with UiPath/Agents#6256.

🤖 Generated with Claude Code

apetraru-uipath and others added 2 commits September 13, 2026 01:24
Adds an optional `attachments` keyword to GuardrailsService.evaluate_guardrail and
a GuardrailAttachment model (id, fileName, mimeType, url), so a caller can tell the
guardrails backend which files a guardrail should inspect instead of the backend
seeing only attachment metadata embedded in the payload string.

Also forwards a 60s timeout when attachments are present. The default client
timeout is 30s and RequestSpec.timeout was constructed but never passed, so a
validate call that waits on server-side file fetching would have timed out.

Backward compatible: without `attachments` — or with an empty list — the request
body is byte-identical to today, so an older backend is unaffected.

uipath-platform: 31 tests pass (+4); ruff, ruff format and mypy clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Carries the GuardrailAttachment model and the `attachments` argument on
GuardrailsService.evaluate_guardrail.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

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.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Extends uipath-platform guardrail evaluation to send file attachment references to the backend.

Changes:

  • Adds and exports GuardrailAttachment.
  • Serializes attachments and applies an extended timeout.
  • Adds tests and bumps the package version.
File summaries
File Description
packages/uipath-platform/tests/services/test_guardrails_service.py Updated as part of this pull request.
packages/uipath-platform/src/uipath/platform/guardrails/guardrails.py Updated as part of this pull request.
packages/uipath-platform/src/uipath/platform/guardrails/_guardrails_service.py Updated as part of this pull request.
packages/uipath-platform/src/uipath/platform/guardrails/init.py Updated as part of this pull request.
packages/uipath-platform/pyproject.toml Updated as part of this pull request.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Lite

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

[project]
name = "uipath-platform"
version = "0.2.28"
version = "0.2.29"

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.

Fixed in 49b5032 — all three lockfiles relocked; CI's uv lock --check is green.

🤖 Generated with Claude Code

input_data: str | dict[str, Any],
guardrail: BuiltInValidatorGuardrail,
*,
attachments: list[GuardrailAttachment] | None = None,

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.

Fixed in e831652: an input_processor redacts attachments[*].url before the span records inputs, leaving payload, guardrail and attachment identity intact. Two tests cover it, including a no-mutation check.

🤖 Generated with Claude Code

Comment on lines +173 to +174
if attachments:
request_kwargs["timeout"] = _ATTACHMENT_VALIDATE_TIMEOUT_SECONDS

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.

Added in e831652: one test asserts the attachment-bearing call forwards timeout=60.0 (via httpx_mock request extensions), and one asserts the default path does not.

🤖 Generated with Claude Code

apetraru-uipath and others added 2 commits September 14, 2026 16:53
CI runs `uv lock --check`; bumping the version in pyproject.toml without
regenerating the lockfiles left both packages/uipath-platform/uv.lock and
packages/uipath/uv.lock stale (uipath resolves uipath-platform through
[tool.uv.sources]).

ruff check and ruff format clean across all three packages; guardrails service
tests still 31 passed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Traced records a function's arguments on the OpenTelemetry span by default, so
every GuardrailAttachment.url — a short-lived SAS credential — was landing in
input.value. Flagged by Copilot on #1895.

An input_processor now replaces attachments[*].url with "<redacted>" and leaves
everything else (payload, guardrail, attachment identity) intact; that is
tighter than hide_input=True, which would drop the useful part of the span too.

Also adds the two tests Copilot noted were missing: that an attachment-bearing
evaluation forwards the 60s timeout, and that the default path does not.

uipath-platform: 35 tests pass (+4); ruff, ruff format, mypy clean.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🚨 Heads up: uipath-langchain cross-tests are FAILING 🚨

Your changes may break the uipath-langchain-python integration.

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants