Skip to content

UseConversation WebRTC branches#497

Draft
AngeloGiacco wants to merge 2 commits intomainfrom
cursor/useconversation-webrtc-branches-5a6f
Draft

UseConversation WebRTC branches#497
AngeloGiacco wants to merge 2 commits intomainfrom
cursor/useconversation-webrtc-branches-5a6f

Conversation

@AngeloGiacco
Copy link
Copy Markdown
Collaborator

Add optional branch parameter to SessionConfig to enable specifying agent branches for WebRTC connections, consistent with WebSocket functionality.


Slack Thread

Open in Cursor Open in Web

- Add optional 'branch' parameter to BaseSessionConfig in BaseConnection.ts
- Update constructOverrides to include branch in initiation event for WebRTC
- Add comprehensive tests for branch parameter in overrides.test.ts

This allows users to specify which agent branch to use during WebRTC sessions,
similar to how it's already supported in WebSocket connections.
@cursor
Copy link
Copy Markdown

cursor bot commented Feb 5, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@AngeloGiacco
Copy link
Copy Markdown
Collaborator Author

@cursor did you read my prompt ? It's a parameter of the livekit token endpoint and parameter of the websocket not an override. Redo it start from scratch and think carefully , check how we currently get the token and add a branch id param nothing else needs to be changed

@cursor
Copy link
Copy Markdown

cursor bot commented Feb 5, 2026

I've corrected the implementation. Here's what the fix does:

Changes Made:

  1. WebRTCConnection.ts - Added branch as a query parameter to the token endpoint URL:

    let url = `${origin}/v1/convai/conversation/token?agent_id=${config.agentId}&source=${source}&version=${version}`;
    if (config.branch) {
      url += `&branch=${encodeURIComponent(config.branch)}`;
    }
  2. WebSocketConnection.ts - Added branch as a query parameter to the WebSocket URL:

    url = `${origin}${WSS_API_PATHNAME}${config.agentId}&source=${source}&version=${version}`;
    if (config.branch) {
      url += `&branch=${encodeURIComponent(config.branch)}`;
    }
  3. overrides.ts - Reverted the incorrect override changes (branch is NOT an override)

  4. BaseConnection.ts - The branch?: string parameter remains in BaseSessionConfig (from the previous commit)

Usage:

const { startSession } = useConversation({
  agentId: "your-agent-id",
  branch: "feature-branch", // Optional - added to URL query params
  connectionType: "webrtc",
});

The branch parameter is now correctly passed as a URL query parameter to both the LiveKit token endpoint and the WebSocket connection URL, properly URL-encoded.

Open in Cursor Open in Web

- Add branch query parameter to WebRTC token endpoint URL
- Add branch query parameter to WebSocket connection URL
- Remove incorrect override implementation
- Branch parameter is properly URL-encoded

The branch parameter is now correctly passed as a query parameter to:
- /v1/convai/conversation/token?...&branch=<branch> (WebRTC)
- /v1/convai/conversation?...&branch=<branch> (WebSocket)
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