AI Focus

webrtc p2p agent swarm

Coordinating state across two open tabs or two collaborators usually means routing every update and note through a central backend database even when both browsers are online simultaneously. Using a server strictly for the brief WebRTC SDP handshake and pushing task state directly peer-to-peer over RTCDataChannel keeps application data off the signaling server and resilient offline in IndexedDB.

Hypothesis

Using Cloudflare Durable Objects solely for ephemeral SDP/ICE handshakes while pushing CRDT task logs directly peer-to-peer over RTCDataChannel + IndexedDB keeps multi-tab and collaborator state private and functional off-server.

What confirms it: Two peers exchange CRDT deltas end-to-end with zero task bytes sent to the signaling server (422 rejects payload writes on SwarmSignaling), maintaining consistent order across reconnects via navigator.locks.

What falsifies or bounds it: Restrictive NATs/firewalls block direct UDP peer connections frequently enough to require TURN relay fallback for consumer networks.

Two-peer WebRTC RTCDataChannel workbench using a Durable Object strictly for ephemeral SDP/ICE handshakes while syncing CRDT task logs into IndexedDB with Web Locks coordination. Open webrtc p2p agent swarm full screen ↗

What this lab tests

WebRTC Agent Swarm (GitHub) connects two browser peers over RTCDataChannel using a Durable Object (SwarmSignaling) solely for ephemeral SDP/ICE handshakes while persisting CRDT logs locally in IndexedDB with navigator.locks leader coordination.

Open questions

  • How well does BroadcastChannel + navigator.locks handle same-origin multi-tab election without dropping WebRTC data channels on tab close?
  • What compact CRDT tombstoning keeps IndexedDB storage bounded across long agent swarms?

Iteration log

  • — Built Peer A/B WebRTC RTCDataChannel CRDT workbench with SQLite Durable Object signaling (422 data guard) and IndexedDB persistence.
  • — Reordered workbench above setup docs, added live HTTP 422 signaling-guard probe and CSP-safe DOM syntax highlighting, hardened 700px embed responsiveness, and added no-cache static headers.

Primitives tested: RTCDataChannel, IndexedDB, Web Locks API, Durable Object SDP Signaling.

This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.

More in peer-to-peer coordination, pip surfaces & malleable plugins

Connected labs

← peer-to-peer coordination, pip surfaces & malleable plugins · All labs