Skip to content

feat(guardrails): send execution source and job key headers#1739

Open
valentinabojan wants to merge 9 commits into
mainfrom
valentinabojan/guardrails-source-job-headers
Open

feat(guardrails): send execution source and job key headers#1739
valentinabojan wants to merge 9 commits into
mainfrom
valentinabojan/guardrails-source-job-headers

Conversation

@valentinabojan

Copy link
Copy Markdown
Contributor

Guardrail validation calls now send the execution source (x-uipath-agenthub-config) and job key (x-uipath-jobkey) headers for licensing/metering correlation, mirroring the licensing flow. The source is derived from the executing CLI command — runruntime, debug/devplayground, evaleval (with a debug-rooted job treated as playground) — and exposed via the new UIPATH_EXECUTION_SOURCE env var. It's set at the top of the CLI command handlers, before the runtime is constructed, so it works for both coded and low-code agents since both execute through the uipath CLI. The generic GuardrailsService reads these from config (UiPathConfig.execution_source, existing job_key) and omits each header when its value is unset. Added unit tests covering both the present and absent cases.

🤖 Generated with Claude Code

Guardrail validation calls now carry x-uipath-agenthub-config (execution
source) and x-uipath-jobkey headers for licensing/metering correlation,
mirroring the licensing flow.

The source is derived from the executing CLI command (run -> runtime,
debug/dev -> playground, eval -> eval) and exposed via the
UIPATH_EXECUTION_SOURCE env var, so it works for both coded and low-code
agents since both run through the uipath CLI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 22, 2026 14:47
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Jun 22, 2026
Also drops the "(AgentHub config)" note from the execution_source docstring.

Co-Authored-By: Claude Opus 4.8 <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.

Pull request overview

This PR adds correlation metadata to guardrail validation requests by propagating the CLI execution “source” and orchestrator job key into HTTP headers, aligning guardrails with existing licensing/metering flows.

Changes:

  • Set UIPATH_EXECUTION_SOURCE at the start of CLI agent-executing commands (run, debug, dev, eval) via a new execution-source resolver.
  • Send x-uipath-agenthub-config (execution source) and x-uipath-jobkey (job key) headers on guardrail validation requests, omitting each when unset.
  • Add unit tests to verify presence/absence of the new headers on outgoing guardrails requests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/uipath/src/uipath/_cli/cli_run.py Sets execution source for run before runtime construction.
packages/uipath/src/uipath/_cli/cli_eval.py Sets execution source for eval before evaluation execution starts.
packages/uipath/src/uipath/_cli/cli_dev.py Sets execution source for dev before launching the developer console/runtime.
packages/uipath/src/uipath/_cli/cli_debug.py Sets execution source for debug before runtime/debug setup.
packages/uipath/src/uipath/_cli/_utils/_execution_source.py New mapping logic from CLI command → execution source env var.
packages/uipath-platform/src/uipath/platform/guardrails/_guardrails_service.py Adds execution source + job key headers to guardrails validate requests.
packages/uipath-platform/src/uipath/platform/common/constants.py Introduces UIPATH_EXECUTION_SOURCE env var constant.
packages/uipath-platform/src/uipath/platform/common/_job_context.py Adds header_execution_source() helper alongside existing job key header helper.
packages/uipath-platform/src/uipath/platform/common/_config.py Exposes UiPathConfig.execution_source via the new env var.
packages/uipath-platform/tests/services/test_guardrails_service.py Adds tests ensuring headers are present when set and omitted when unset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/uipath/src/uipath/_cli/_utils/_execution_source.py Outdated
Valentina Bojan and others added 6 commits June 22, 2026 17:50
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Use a dedicated x-uipath-execution-source header instead of reusing
x-uipath-agenthub-config.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mirror get_execution_type's plain command->type mapping; the
playground reclassification was a licensing-only concern.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Raise uipath -> uipath-platform pin to >=0.1.72 (dependency-bump check)
- Regenerate uv.lock files for the version bumps (--locked sync)
- Add unit tests for set_execution_source and header_execution_source

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ails-source-job-headers

# Conflicts:
#	packages/uipath/pyproject.toml
#	packages/uipath/uv.lock
@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 →

…ails-source-job-headers

# Conflicts:
#	packages/uipath-platform/pyproject.toml
#	packages/uipath-platform/uv.lock
#	packages/uipath/pyproject.toml
#	packages/uipath/uv.lock
@sonarqubecloud

Copy link
Copy Markdown

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.

4 participants