Skip to content

feat: propagate RunAsMe to child process tool jobs#764

Merged
dsuresh-ap merged 1 commit intomainfrom
feature/run-as-me-propagation-JAR-9434
Apr 16, 2026
Merged

feat: propagate RunAsMe to child process tool jobs#764
dsuresh-ap merged 1 commit intomainfrom
feature/run-as-me-propagation-JAR-9434

Conversation

@dsuresh-ap
Copy link
Copy Markdown
Member

Summary

  • For conversational agents with a user token (sub_type == "user"), automatically pass RunAsMe=True to child StartJobs calls
  • Adds _should_run_as_me() helper that checks JWT token type + isConversational config, cached per process lifetime
  • Depends on: feat: add RunAsMe support to ProcessesService uipath-python#1567 (adds run_as_me param to ProcessesService)

Context

JAR-9434 — Conversational Agent API Workflow tools fail with HTTP 409 ("no unattended robot") because RunAsMe is not propagated to child StartJobs calls. This PR detects user identity from the JWT token and conversational agent config, then propagates RunAsMe accordingly.

Test plan

  • test_run_as_me_true_for_conversational_user_token — user token + conversational → RunAsMe=True
  • test_run_as_me_none_for_non_user_token — robot token → RunAsMe=None (no change)
  • test_run_as_me_none_for_non_conversational_agent — autonomous agent → RunAsMe=None (no change)
  • Integration: deploy to alpha, run Conversational Agent with API Workflow tool in shared folder

🤖 Generated with Claude Code

@dsuresh-ap dsuresh-ap force-pushed the feature/run-as-me-propagation-JAR-9434 branch from 2ff7cf4 to 6f2b82a Compare April 15, 2026 13:01
@dsuresh-ap dsuresh-ap requested a review from maxduu April 15, 2026 13:20
Comment thread src/uipath_langchain/agent/tools/process_tool.py Outdated

sub_type = get_claim_from_token("sub_type")
is_conversational = UiPathConfig.is_conversational
is_user_token = sub_type == "user"
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.

Were you able to verify that when running with runasme=false, the sub_type isn't "user"?

Copy link
Copy Markdown
Member Author

@dsuresh-ap dsuresh-ap Apr 16, 2026

Choose a reason for hiding this comment

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

With my user auth token:

[2026-04-16 12:05:03,579][INFO] Token sub_type='service.external'
[2026-04-16 12:05:03,579][INFO] RunAsMe decision: is_conversational=True, is_user_token=False, run_as_me=False
image

With an external app token:

[2026-04-16 12:06:06,944][INFO] Token sub_type='user'
[2026-04-16 12:06:06,944][INFO] RunAsMe decision: is_conversational=True, is_user_token=True, run_as_me=True
image

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.

Awesome, thanks!

Comment thread src/uipath_langchain/agent/tools/process_tool.py Outdated
_cached_should_run_as_me: dict[str, bool] = {}


def _should_run_as_me() -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

An observation is that this approach makes all conversational agents' (even deployed ones) started processes run under the same identity via run_as_me: True. Is this intended?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes depending on the token type of the agent

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.

Yup, for deployed conversational agents (in shared folders) running with user-token, CAS will start them with RunAsMe=true, so this is intended

Comment thread src/uipath_langchain/agent/tools/process_tool.py Outdated
@dsuresh-ap dsuresh-ap force-pushed the feature/run-as-me-propagation-JAR-9434 branch from 39f1e91 to c1cc71e Compare April 16, 2026 16:17
For conversational agents with a user token, automatically set
RunAsMe=True on child StartJobs calls so API Workflows execute under
the user's identity instead of requiring an unattended robot.

Computes run_as_me top-down in tool_factory using agent.is_conversational
and JWT sub_type, then passes it to create_process_tool.

JAR-9434

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dsuresh-ap dsuresh-ap force-pushed the feature/run-as-me-propagation-JAR-9434 branch from e0ef642 to 98efb39 Compare April 16, 2026 16:30
@dsuresh-ap dsuresh-ap merged commit b8aa0b2 into main Apr 16, 2026
42 of 45 checks passed
@dsuresh-ap dsuresh-ap deleted the feature/run-as-me-propagation-JAR-9434 branch April 16, 2026 17:30
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.

3 participants