feat(context): add execution_source derived from command#132
Merged
valentinabojan merged 2 commits intoJun 24, 2026
Conversation
Add UiPathRuntimeContext.execution_source, derived from the executing command (run -> runtime, debug/dev -> playground, eval -> eval) in with_defaults. This lets execution metadata flow through the existing context boundary instead of an out-of-band env var, so downstream platform calls (e.g. guardrails) can identify the run context and it stays correctly scoped in concurrent runs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a first-class execution_source field to UiPathRuntimeContext, deriving it from the executing command in with_defaults() so downstream platform clients can reliably scope execution metadata without relying on environment variables.
Changes:
- Introduce
UiPathRuntimeContext.execution_sourceand a command→source mapping. - Derive
execution_sourceinUiPathRuntimeContext.with_defaults()without overriding an explicitly provided value. - Add unit tests for the mapping behavior and bump package version to
0.11.4.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/uipath/runtime/context.py |
Adds execution_source field and derives it from command in with_defaults(). |
tests/test_context.py |
Adds tests validating derived execution_source behavior. |
pyproject.toml |
Bumps package version to 0.11.4. |
uv.lock |
Updates locked package version to 0.11.4. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
valentinabojan
pushed a commit
that referenced
this pull request
Jun 24, 2026
Move derivation out of with_defaults into a model_validator so it fires on the plain-constructor path too (e.g. dev/init), and never assign None for unmapped commands so the field stays absent under model_dump(exclude_unset=True). with_defaults re-applies it since it mutates command via setattr after construction. Addresses Copilot review feedback on PR #132. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
radu-mocanu
reviewed
Jun 24, 2026
Move derivation out of with_defaults into a model_validator so it fires on the plain-constructor path too (e.g. dev/init), and never assign None for unmapped commands so the field stays absent under model_dump(exclude_unset=True). with_defaults re-applies it since it mutates command via setattr after construction. Addresses Copilot review feedback on PR #132. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
adc667a to
711246a
Compare
|
radu-mocanu
approved these changes
Jun 24, 2026
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.



Adds a first-class
execution_sourcefield toUiPathRuntimeContext, derived from the executing command (run→runtime,debug/dev→playground,eval→eval; unset for other commands such asinit/pack, and an explicitly-passed value is never overwritten).The derivation runs in a
model_validator(mode="after")so it fires on every construction path — both the plain constructor (e.g.dev/init, which build the context directly) andwith_defaults. Unmapped commands are left genuinely unset (never assignedNone), so the field is absent undermodel_dump(exclude_unset=True). Sincewith_defaultsmutatescommandviasetattrafter construction (which does not re-run the validator), it re-applies the derivation through the same guarded helper.This lets execution metadata flow through the existing runtime-context boundary — the same way
command/job/tracestate already does — rather than via an out-of-band env var, so it stays correctly scoped in concurrent/eval runs. Downstream platform clients (e.g. the guardrails service) will read this to set thex-uipath-guardrails-sourceheader.Part 1 of a two-repo change; the
uipath-pythonside will consume this field viaUiPathExecutionContext.🤖 Generated with Claude Code