Repository navigation
fix(guardrails): drop the client evaluate_guardrail span in jobs - #1997
Open
daniel-joica wants to merge 4 commits into
Open
daniel-joica wants to merge 4 commits into
daniel-joica wants to merge 4 commits into
Conversation
…712] In a job, the Guardrails Service publishes its own span for each evaluation (e.g. "PII Detection"), so the client-side evaluate_guardrail span duplicated it. Skip the client span when a job key is set; local runs keep it, since the service span does not reach their trace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the guardrail tracing change.
No open issues 🎉
What changed in this PR
This PR removes duplicate client-side guardrail evaluation spans from job traces while preserving local tracing in the UiPath Python SDK.
Changes:
- Selects the traced or untraced evaluation path per call based on
UIPATH_JOB_KEY, without changing the public API. - Adds tests for job span suppression, caller trace propagation, and local span retention.
- Bumps
uipath-platformto 0.3.8 and updates both lockfiles.
| File | Description |
|---|---|
packages/uipath/uv.lock |
Updates the platform dependency version to 0.3.8. |
packages/uipath-platform/uv.lock |
Synchronizes the platform package version to 0.3.8. |
packages/uipath-platform/tests/services/test_guardrails_service.py |
Adds job and local tracing regression tests. |
packages/uipath-platform/src/uipath/platform/guardrails/_guardrails_service.py |
Skips the client evaluation span in jobs while retaining it locally. |
packages/uipath-platform/pyproject.toml |
Bumps the platform package version to 0.3.8. |
Review effort: Balanced
Addresses Sonar findings on #1997: reduce the cognitive complexity of the validate call by moving the payload, headers, request and result mapping into their own helpers (no behaviour change), and split a composite test assertion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚨 Heads up:
|
Contributor
Author
apetraru-uipath
approved these changes
Nov 18, 2026
…te-span-AL-712 # Conflicts: # packages/uipath-platform/pyproject.toml # packages/uipath-platform/src/uipath/platform/guardrails/_guardrails_service.py # packages/uipath-platform/uv.lock # packages/uipath/uv.lock
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





What changed?
Every guardrail evaluation produced two spans side by side in a job's trace:
evaluate_guardrail, created on the client by@tracedonGuardrailsService.evaluate_guardrail. It holds only the method's input and output.guardrailEvaluationspan (e.g.PII Detection). It holds the configuration, the validation result, the details and the payload.The goal is to keep only the service's span.
Changes:
UIPATH_JOB_KEYset),evaluate_guardrailno longer opens a client span. The service's span is the only evaluation span.uipath run,uipath dev), the client span stays. The service's span never reaches a local trace, so without the client span a local run would show no evaluation at all. This is the same job-only rule fix: resolve OpenTelemetry tracing architecture issues #1197 in uipath-langchain uses for client LLM spans.@traceddecides whether to record when it's applied, not per call. So the publicevaluate_guardrailnow picks a traced or an untraced private path on each call. The request, the response handling and the public signature are unchanged, so callers need no changes: the uipath-langchain middlewares, the guardrail nodes and the@guardraildecorators.evaluate_guardrailunderPII_Detection_before_model, so the trace just loses the duplicate._build_validate_payload,_build_validate_headers,_send_validate_request(including the 403 handling) and_to_validation_result. There is no behaviour change. Twoexcept Exception: raiseblocks that did nothing are removed, and the inlineimport jsonmoves to the top of the file.Versions:
uv.lockfiles are refreshed.How has this been tested?
TestEvaluateGuardrailSpan:evaluate_guardrailspan.evaluate_guardrailis recorded under the caller.ruff check,ruff format --checkandmypyare clean.check_version_uniqueness.pyandcheck_dependency_version_bumps.pypass, anduv lock --lockedis current.PII Detection,Harmful Content Detection, ...) and noevaluate_guardrail. The same agent with the released uipath-platform still shows oneevaluate_guardrailper check.🤖 Generated with Claude Code
Development Packages
uipath-platform
uipath