Skip to content

feat: send conversation owner id header on CAS websocket handshake [JAR-9965]#1712

Open
scottcmg wants to merge 4 commits into
mainfrom
feat/urt-handshake-synthetic-user-id
Open

feat: send conversation owner id header on CAS websocket handshake [JAR-9965]#1712
scottcmg wants to merge 4 commits into
mainfrom
feat/urt-handshake-synthetic-user-id

Conversation

@scottcmg

@scottcmg scottcmg commented Jun 12, 2026

Copy link
Copy Markdown

TL;DR

The conversational chat/voice bridge forwards the conversation owner id (context.synthetic_user_id) as the X-UiPath-Internal-SyntheticUserId header on the CAS WebSocket handshake, so CAS can validate Robot connections for RunAsMe=false conversations.

Solution

  • _cli/_chat/_bridge.py (get_chat_bridge) and _cli/_chat/_voice_bridge.py (get_voice_bridge): add the header when context.synthetic_user_id is set. Uses getattr(context, "synthetic_user_id", None), so it's a no-op when absent (backward compatible).
  • Tests in tests/cli/chat/test_bridge.py + test_voice_bridge.py (header present when set, omitted when absent).

Depends on

uipath-runtime exposing context.synthetic_user_id (mapped from fpsProperties.conversationalService.syntheticUserId). Consumed by AgentInterfaces CAS, which validates the presented id against conversation.user_id on the handshake.

Notes

  • Local testing required boosting the socket.io namespace-connect wait_timeout past its 1s default — CAS's socket-auth middleware does network I/O (JWKS / OIDC discovery) and can exceed 1s, so the client gave up before CAS granted (One or more namespaces failed to connect). Kept wait_timeout at default 1s for this PR. Worth considering extending if timeouts show in alpha on merge.

@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Jun 12, 2026
@scottcmg scottcmg changed the title feat: send conversation owner id header on CAS websocket handshake feat: send conversation owner id header on CAS websocket handshake [JAR-9965] Jun 12, 2026
@scottcmg scottcmg force-pushed the feat/urt-handshake-synthetic-user-id branch from f72d183 to 95583d1 Compare June 12, 2026 02:57
get_chat_bridge / get_voice_bridge forward context.synthetic_user_id as the
X-UiPath-Internal-SyntheticUserId handshake header so CAS can validate Unified Runtime
Robot connections for RunAsMe=false conversations. No-op when the context field is unset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@scottcmg scottcmg force-pushed the feat/urt-handshake-synthetic-user-id branch from 95583d1 to 1941383 Compare June 12, 2026 03:05
scottcmg and others added 2 commits June 12, 2026 09:29
@scottcmg scottcmg marked this pull request as ready for review June 12, 2026 17:34
Copilot AI review requested due to automatic review settings June 12, 2026 17:34

Copilot AI left a comment

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.

Pull request overview

This PR extends the conversational chat and voice CLI bridges to forward the conversation owner ID (context.synthetic_user_id) to CAS via a new X-UiPath-Internal-SyntheticUserId header during the WebSocket handshake, enabling CAS to validate Robot connections for RunAsMe=false conversations.

Changes:

  • Add X-UiPath-Internal-SyntheticUserId to CAS handshake headers in both chat and voice bridges when context.synthetic_user_id is present.
  • Add unit tests covering presence/absence of the new header for both bridges.
  • Bump the uipath package version to 2.10.82 (and update uv.lock accordingly).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/uipath/src/uipath/_cli/_chat/_bridge.py Adds optional X-UiPath-Internal-SyntheticUserId header for CAS socket.io handshake (chat).
packages/uipath/src/uipath/_cli/_chat/_voice_bridge.py Adds optional X-UiPath-Internal-SyntheticUserId header for CAS socket.io handshake (voice).
packages/uipath/tests/cli/chat/test_bridge.py Adds tests asserting the synthetic user id header is included/omitted appropriately for chat bridge.
packages/uipath/tests/cli/chat/test_voice_bridge.py Adds tests asserting the synthetic user id header is included/omitted appropriately for voice bridge.
packages/uipath/pyproject.toml Bumps package version to 2.10.82.
packages/uipath/uv.lock Updates lockfile entry for the local uipath package version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 525 to 526
"X-UiPath-ConversationId": context.conversation_id,
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch — fixed in 948cfa3. Dropped the f"{...}" wrapper so the or os.environ.get(...) fallback works (matches the voice bridge), and added a regression test for the env fallback when tenant_id/org_id are None.

f"{context.tenant_id}" yields the truthy string "None" when tenant_id
is None, so the `or os.environ.get(...)` env fallback was dead code and
the handshake sent a literal "None" id. Use the bare value like the voice
bridge already does, and add a regression test for the env fallback.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🚨 Heads up: uipath-langchain cross-tests are FAILING 🚨

Your changes may break the uipath-langchain-python integration.

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

@maxduu maxduu self-requested a review June 13, 2026 02:35

@maxduu maxduu left a comment

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants