feat: propagate run_as_me for conversational tools except rpa workflows #981
Open
maxduu wants to merge 4 commits into
Open
feat: propagate run_as_me for conversational tools except rpa workflows #981maxduu wants to merge 4 commits into
maxduu wants to merge 4 commits into
Conversation
The tool factory previously inferred RunAsMe by inspecting the token's sub_type claim (== "user"), which was misclassifying tokens and preventing RunAsMe from propagating to child process / API-workflow tool invocations. create_tools_from_resources now takes an explicit run_as_me: bool parameter. Callers resolve it from UiPathRuntimeContext.conversational_run_as_me (populated from fpsProperties.conversationalService.runAsMe on the harness side). Depends on: - UiPath/uipath-runtime-python#148 (adds the context field) - UiPath/uipath-agents-python (threads the value from context to caller) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 task
There was a problem hiding this comment.
Pull request overview
Removes implicit RunAsMe inference based on token claims and instead makes run_as_me an explicit input to create_tools_from_resources, ensuring the decision is owned by the caller (e.g., runtime context) and correctly propagates to process tool creation.
Changes:
- Deleted token
sub_typeinspection logic and the derivedrun_as_medecision insidecreate_tools_from_resources. - Added
run_as_me: bool = Falseparameter tocreate_tools_from_resourcesand threaded it through tocreate_process_tool. - Added tests verifying
run_as_me=Truepropagation and the defaultFalsebehavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/uipath_langchain/agent/tools/tool_factory.py |
Adds explicit run_as_me parameter and forwards it to process tool creation; removes token-claim-based inference. |
tests/agent/tools/test_tool_factory.py |
Adds coverage to ensure run_as_me is forwarded and defaults to False when omitted. |
|
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.



Summary
Ensures conversational-agents running as the user-identity propagates it to process-based tools as well, except for RPA Workflows.
sub_type == "user"inspection thatcreate_tools_from_resourcespreviously used to inferRunAsMe- this was not working before as the real token isrobot.useron Serverless. This PR refactors it to instead read it from a contextUiPathRuntimeContext.conversational_run_as_me, (populated fromfpsProperties.conversationalService.runAsMeon the uipath-runtime side, which is already merged).AgentToolType.PROCESS) from RunAsMe propagation. RPA Workflows remain unattended until attended local robot execution on the user's desktop is implemented. This also ensures we don't regress customers currently relying on RPA Workflows using shared identity by default.Related PRs
Test plan
uv run pytest tests/agent/tools/test_tool_factory.py tests/agent/tools/test_process_tool.py --no-cov— 46 passed (includes new tests: dispatcher forwards conversational_run_as_me; create_process_tool propagates for non-RPA types and suppresses for PROCESS).just lintclean.