Skip to content

feat(webrtc): send robot_id through the broker transport#2492

Draft
spomichter wants to merge 1 commit into
feat/webrtc-transportfrom
feat/webrtc-robot-id
Draft

feat(webrtc): send robot_id through the broker transport#2492
spomichter wants to merge 1 commit into
feat/webrtc-transportfrom
feat/webrtc-robot-id

Conversation

@spomichter

Copy link
Copy Markdown
Contributor

Stacks on #2048 (base = feat/webrtc-transport) — does not modify it.

What

Wires robot_id end-to-end on the transport path so one API key across multiple robots registers as distinct robots:

  • GlobalConfig.robot_id (per-machine id; auto --robot-id flag; distinct from robot_model).
  • run CLI exports ROBOT_ID to env before workers spawn — a BrokerProvider isn't a Module, so it gets no g; env is the only channel that reaches a forkserver worker.
  • BrokerProvider reads global_config.robot_id (hydrated from ROBOT_ID in the worker) and sends it as body.robot_id on session create. TELEOP_ROBOT_ID dropped.

Why

The broker (dimensional-teleop, deployed) already consumes body.robot_id for tenant-scoped dedup — but nothing populated it from the new field, so it wasn't actually sent. This is the client half.

Test

ROBOT_ID=lab-go2-7GlobalConfig.robot_idBrokerProvider._robot_id → sent as body.robot_id. Verified (assert).

Run: dimos --robot-id lab-go2-7 run teleop-hosted-go2-transport. Supersedes #2490 (the standalone field PR off main) — close that.

@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the TELEOP_ROBOT_ID env-var fallback from BrokerProvider and makes robot_id a per-transport config field, flowing through BrokerConfig via CloudflareTransport/CloudflareVideoTransport kwargs. The core broker change is correct: BrokerConfig(robot_id=...) now rides the pickled config to the provider singleton, so two robots on one machine (or two transports in one process) stay distinct as long as their configs differ.

  • broker.py: self._robot_id = config.robot_id or ""TELEOP_ROBOT_ID dropped; robot_id is now config-only (not env-backed), sent as an optional field on the broker session payload.
  • blueprints.py: Comment update explaining the per-transport pattern, with an example that needs clarification — the example shows robot_id on only the data transport, which would silently create two broker sessions when a CloudflareVideoTransport is also present.

Confidence Score: 4/5

Safe to merge as-is, but the comment example in blueprints.py actively promotes a usage pattern that silently splits data and video into two separate broker sessions if followed literally.

The broker.py change itself is clean and intentional. The concern is the new comment in blueprints.py: it shows robot_id on CloudflareTransport without mentioning that CloudflareVideoTransport must carry the same robot_id to share the provider singleton. A user who follows the example will end up with two separate broker sessions — one carrying data channels and one carrying the video track — with no error, just silently broken teleop video.

dimos/teleop/quest_hosted/blueprints.py — the comment example needs a corresponding CloudflareVideoTransport(robot_id=...) to avoid misleading callers.

Important Files Changed

Filename Overview
dimos/protocol/pubsub/impl/webrtc/providers/broker.py Removes TELEOP_ROBOT_ID env-var fallback; robot_id now comes exclusively from BrokerConfig.robot_id. Logic is correct and the per-transport singleton pattern is properly preserved.
dimos/teleop/quest_hosted/blueprints.py Comment changes only, but the example snippet showing robot_id on CloudflareTransport without also setting it on CloudflareVideoTransport would mislead users into splitting data and video into two separate broker sessions.

Sequence Diagram

sequenceDiagram
    participant Blueprint as Blueprint Definition
    participant CT as CloudflareTransport(robot_id="go2-a")
    participant CVT as CloudflareVideoTransport(no robot_id)
    participant BC1 as BrokerConfig(robot_id="go2-a")
    participant BC2 as BrokerConfig(robot_id="")
    participant Cache as Provider Cache (keyed by config equality)
    participant BP1 as BrokerProvider A (session A)
    participant BP2 as BrokerProvider B (session B)
    participant Broker as dimensional-teleop Broker

    Blueprint->>CT: "CloudflareTransport(robot_id="go2-a")"
    Blueprint->>CVT: CloudflareVideoTransport()
    CT->>BC1: "BrokerConfig(robot_id="go2-a")"
    CVT->>BC2: "BrokerConfig(robot_id="")"
    BC1->>Cache: cache.get(BC1) miss
    Cache->>BP1: create BrokerProvider
    BC2->>Cache: cache.get(BC2) miss (different key)
    Cache->>BP2: create BrokerProvider
    BP1->>Broker: "POST /sessions {robot_id: go2-a, sdp_offer: ...}"
    BP2->>Broker: "POST /sessions {robot_id: empty, sdp_offer: ...}"
    Note over BP1,BP2: Two separate broker sessions - data channels on A, video on B
Loading

Reviews (3): Last reviewed commit: "feat(webrtc): robot_id as a per-transpor..." | Re-trigger Greptile

@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Flag Coverage Δ
OS-ubuntu-24.04-arm 64.38% <100.00%> (+0.78%) ⬆️
OS-ubuntu-latest 65.26% <100.00%> (+0.83%) ⬆️
Py-3.10 65.26% <100.00%> (+0.82%) ⬆️
Py-3.11 65.26% <100.00%> (+0.82%) ⬆️
Py-3.12 65.26% <100.00%> (+0.82%) ⬆️
Py-3.13 65.26% <100.00%> (+0.82%) ⬆️
Py-3.14 65.27% <100.00%> (+0.82%) ⬆️
Py-3.14t 65.26% <100.00%> (+0.83%) ⬆️
SelfHosted-Large 30.52% <0.00%> (?)
SelfHosted-Linux 38.64% <0.00%> (+0.45%) ⬆️
SelfHosted-macOS 37.29% <0.00%> (+0.41%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...os/protocol/pubsub/impl/webrtc/providers/broker.py 31.44% <100.00%> (ø)
dimos/teleop/quest_hosted/blueprints.py 100.00% <ø> (ø)

... and 56 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@spomichter spomichter force-pushed the feat/webrtc-robot-id branch from 938df64 to 7bb950e Compare June 14, 2026 11:02
robot_id rides the pickled BrokerConfig to the provider, so multiple
robots under one key — even two transports in one process — stay
distinct: CloudflareTransport("cmd_unreliable", TwistStamped, robot_id="go2-a").
A process/env-global id can't distinguish them, so no GlobalConfig field
or env bridge; BrokerProvider reads config.robot_id only (TELEOP_ROBOT_ID
dropped).
@spomichter spomichter force-pushed the feat/webrtc-robot-id branch from 7bb950e to 06e8cee Compare June 14, 2026 11:09
@spomichter spomichter marked this pull request as draft June 14, 2026 11:12
Comment on lines +73 to +76
# robot_id is a per-transport kwarg (rides the pickled config to the provider),
# so running several robots off one key just means a distinct id per blueprint —
# e.g. CloudflareTransport("cmd_unreliable", TwistStamped, robot_id="go2-a").
# Omitted here → empty; the broker still keeps sessions distinct by session id.

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.

P1 The example sets robot_id only on CloudflareTransport while leaving CloudflareVideoTransport() with no robot_id. Because ProviderConfig.provider() is a per-process singleton keyed on config equality, a data transport with BrokerConfig(robot_id="go2-a") and a video transport with BrokerConfig(robot_id="") resolve to two different providers — two separate broker sessions. Video lands on one session; data channels on the other, silently breaking teleop. The robot_id must be set identically on every transport in the blueprint that should share a session.

Suggested change
# robot_id is a per-transport kwarg (rides the pickled config to the provider),
# so running several robots off one key just means a distinct id per blueprint —
# e.g. CloudflareTransport("cmd_unreliable", TwistStamped, robot_id="go2-a").
# Omitted here → empty; the broker still keeps sessions distinct by session id.
# robot_id is a per-blueprint label: every transport in the blueprint must carry
# the same robot_id so they all resolve to the same per-process provider
# singleton (configs are compared by equality — a mismatch creates two separate
# broker sessions, splitting data channels from the video track).
# e.g. CloudflareTransport("cmd_unreliable", TwistStamped, robot_id="go2-a"),
# CloudflareVideoTransport(robot_id="go2-a")
# Omitted here → empty; the broker still keeps sessions distinct by session id.

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.

1 participant