Skip to content

fix: remove token sub_type inspection; accept run_as_me from caller#981

Open
maxduu wants to merge 1 commit into
mainfrom
feat/run-as-me-from-caller
Open

fix: remove token sub_type inspection; accept run_as_me from caller#981
maxduu wants to merge 1 commit into
mainfrom
feat/run-as-me-from-caller

Conversation

@maxduu

@maxduu maxduu commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • create_tools_from_resources previously inferred RunAsMe by inspecting the token's sub_type == "user" claim, which was misclassifying tokens and preventing RunAsMe from propagating to child process / API-workflow tool invocations.
  • Removes the token inspection and makes run_as_me: bool an explicit parameter on create_tools_from_resources. Callers resolve it from UiPathRuntimeContext.conversational_run_as_me (populated from fpsProperties.conversationalService.runAsMe on the harness side).

Related PRs

Test plan

  • uv run pytest tests/agent/tools/test_tool_factory.py --no-cov — 15 passed (includes two new tests covering run_as_me=True propagation and the False default).
  • uv run pytest tests/agent/tools/ --no-cov — 746 passed.
  • just lint clean.

🤖 Generated with Claude Code

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

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