Skip to content

feat: propagate run_as_me for conversational tools except rpa workflows #981

Open
maxduu wants to merge 4 commits into
mainfrom
feat/run-as-me-from-caller
Open

feat: propagate run_as_me for conversational tools except rpa workflows #981
maxduu wants to merge 4 commits into
mainfrom
feat/run-as-me-from-caller

Conversation

@maxduu

@maxduu maxduu commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Ensures conversational-agents running as the user-identity propagates it to process-based tools as well, except for RPA Workflows.

  • Removes the not-working token sub_type == "user" inspection that create_tools_from_resources previously used to infer RunAsMe - this was not working before as the real token is robot.user on Serverless. This PR refactors it to instead read it from a context UiPathRuntimeContext.conversational_run_as_me, (populated from fpsProperties.conversationalService.runAsMe on the uipath-runtime side, which is already merged).
  • Exempts RPA workflows (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 lint clean.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_type inspection logic and the derived run_as_me decision inside create_tools_from_resources.
  • Added run_as_me: bool = False parameter to create_tools_from_resources and threaded it through to create_process_tool.
  • Added tests verifying run_as_me=True propagation and the default False behavior.

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.

@sonarqubecloud

Copy link
Copy Markdown

@maxduu maxduu changed the title fix: remove token sub_type inspection; accept run_as_me from caller feat: propagate run_as_me for conversational tools except rpa workflows Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants