By Sagar Shankaran, Founder of CallSphere
Perfect negotiation is the only sane way to handle SDP renegotiation when an AI agent and a browser both want to change tracks. Here is the 2026 pattern.
Key takeaways
Perfect negotiation is the W3C's recommended way to make SDP renegotiation symmetric. For AI voice agents — where the agent might add a tool-call track or the user might enable video mid-call — it is the only pattern that does not deadlock.
A WebRTC session is born from one offer/answer round trip. Anything after that — adding a video track, switching codecs, restarting ICE, hot-swapping the AI model — needs another round trip. If both peers try to start renegotiation at the same time you get glare: two offers in flight, two `signalingState` transitions racing each other, and a connection that ends up half-broken.
Pre-2020 the answer was "have the caller always renegotiate." That breaks the moment your AI agent decides to upgrade itself or the browser swaps cameras. Perfect negotiation, codified in the WebRTC spec and documented on MDN, makes negotiation symmetric so the same code runs on both sides.
For AI voice in 2026 the renegotiation triggers are constant:
Without perfect negotiation each one of these is a potential deadlock.
```mermaid flowchart LR Polite[Polite peer - browser] -- offer --> Signal[(signalling)] Impolite[Impolite peer - AI gateway] -- offer --> Signal Signal -- on collision --> Polite Polite -- rollback + accept other --> Impolite ```
One peer is polite; the other is impolite. On collision the polite peer rolls back its own pending offer and accepts the other side's. The impolite peer ignores the colliding incoming offer. The roles are pre-assigned by your application — typically the server-side AI gateway is impolite, the browser is polite — and they never change for the life of the connection.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
CallSphere assigns the role at `PeerConnection` creation:
The pattern is the same in our Real Estate vertical (OneRoof, /industries/real-estate) and across the other five (healthcare, behavioral health, legal, salon, insurance). Across 37 agents, 90+ tools, and 115+ database tables we deduplicated negotiation logic into one helper that ships to every browser path. SOC 2 audit notes call out the deterministic role assignment as a control. NATS coordinates the gateway across the 6-container pod (CRM, MLS, calendar, SMS, audit, transcript) so a renegotiation does not lose in-flight tool calls. Pricing $149/$499/$1499; affiliates 22% — see /affiliate.
```ts const polite = role === "browser"; let makingOffer = false; let ignoreOffer = false; let isSettingRemoteAnswerPending = false;
pc.onnegotiationneeded = async () => { try { makingOffer = true; await pc.setLocalDescription(); signaler.send({ description: pc.localDescription }); } finally { makingOffer = false; } };
signaler.onmessage = async ({ data: { description, candidate } }) => { if (description) { const readyForOffer = !makingOffer && (pc.signalingState === "stable" || isSettingRemoteAnswerPending); const offerCollision = description.type === "offer" && !readyForOffer; ignoreOffer = !polite && offerCollision; if (ignoreOffer) return;
isSettingRemoteAnswerPending = description.type === "answer";
await pc.setRemoteDescription(description);
isSettingRemoteAnswerPending = false;
if (description.type === "offer") {
await pc.setLocalDescription();
signaler.send({ description: pc.localDescription });
}
} else if (candidate) { try { await pc.addIceCandidate(candidate); } catch (err) { if (!ignoreOffer) throw err; } } }; ```
Should the AI agent be polite? No. Make the user-controlled side polite so the user wins on every collision-free offer.
Does this fix ICE restart too? Yes — `pc.restartIce()` triggers `negotiationneeded` and flows through the same path.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Do I still need rollback? Implicit rollback is automatic when a polite peer calls `setRemoteDescription(offer)` with a colliding offer.
Can both peers be polite? No — that produces deadlocks under bad-luck timing.
Does Pion implement perfect negotiation? Pion exposes the primitives; the pattern is application-level. WebRTC.rs and libwebrtc do the same.
What about Safari? Safari has supported the modern signalingState transitions since 14; perfect negotiation works without polyfills.
Does it work over a third-party SFU? Yes — you negotiate with the SFU on each side; the SFU is just two peers from the perfect-negotiation point of view.
Should I version my signalling messages? Yes — add a `v` field. Renegotiation across a deploy boundary is exactly when version skew bites.
Three rules from shipping perfect negotiation across all six verticals:
The third rule is the controversial one. It produces about 0.4% spurious teardowns in our data. The trade-off is worth it: stuck-state sessions used to be our top-3 voice support ticket, and the kill-switch eliminated them.
Written by
Sagar Shankaran· Founder, CallSphere
Sagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A founder's guide to texto a voz (text-to-speech in Spanish): LATAM vs Castilian voices, free options, and how CallSphere ships Spanish agents.
A founder's guide to the female voice generator landscape: AI female voices, Japanese voices, robot voices, and how CallSphere ships 57+ voices live.
A founder's guide to the Siri voice generator landscape: how AI voice cloning works, what is legal, and how CallSphere uses 57+ voices in production.
A founder's guide to AI voice assistants for ecommerce: customer service, order lookup, and how CallSphere fits in versus virtual receptionists.
Robot text to speech in 2026: how I pick TTS APIs, when robotic voices help, and how CallSphere ships 57+ language voice agents. Hands-on guide.
The customer support specialist role in 2026 is half human, half AI. Here is what the job looks like, the AI tools that pair with it, and how we ship it.
© 2026 CallSphere LLC. All rights reserved.