Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(realtime): restore the trailing newline the SDP validator strips

Ruben Lütkee6d7a2457014
diff --git a/jarvis/codex_app_server.py b/jarvis/codex_app_server.py
index 3b7edd4a62..1f8a297f2e 100644
--- a/jarvis/codex_app_server.py
+++ b/jarvis/codex_app_server.py
@@ -3058,6 +3058,14 @@ class CodexAppServerClient:
if model is not None and model.strip():
params["model"] = model.strip()
if offer_sdp is not None:
+ # The upstream v3 SDP parser reads line-by-line and answers
+ # "Failed to parse offer: failed to unmarshal SDP: EOF" for an
+ # offer whose LAST line has no terminator — which is exactly what
+ # Jarvis's ingress validation produces (it strips the offer).
+ # Proven live 2026-08-01: the identical offer passes WITH a
+ # trailing CRLF and fails without one.
+ if not offer_sdp.endswith("\n"):
+ offer_sdp = offer_sdp + "\r\n"
params["transport"] = {"type": "webrtc", "sdp": offer_sdp}
sdp_subscription = self.subscribe(thread_id) if offer_sdp is not None else None
diff --git a/tests/unit/codex_app_server/test_transport.py b/tests/unit/codex_app_server/test_transport.py
index b911cd7374..21c4abd3ce 100644
--- a/tests/unit/codex_app_server/test_transport.py
+++ b/tests/unit/codex_app_server/test_transport.py
@@ -687,6 +687,15 @@ async def test_realtime_start_subscribes_before_request_and_returns_answer_sdp(
assert thread_params["dynamicTools"] is None
assert thread_params["ephemeral"] is True
assert Path(thread_params["cwd"]).name.startswith("jarvis-codex-voice-")
+ start_params = next(
+ item["params"]
+ for item in messages
+ if item.get("method") == "thread/realtime/start"
+ )
+ # The upstream v3 SDP parser rejects an offer whose last line has no
+ # terminator ("unmarshal SDP: EOF") — and Jarvis's ingress validation
+ # strips offers, so the transport boundary must restore the newline.
+ assert start_params["transport"]["sdp"] == "offer-sdp\r\n"
realtime_params = next(
item["params"] for item in messages if item.get("method") == "thread/realtime/start"
@@ -2087,6 +2096,48 @@ async def test_account_requires_the_openai_authenticated_provider() -> None:
await client._verify_live_chatgpt_account()
+async def test_realtime_start_fails_fast_on_a_realtime_error(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """An upstream refusal (the 403 that ended v1, an invalid offer) must
+ surface as its honest text, never hide behind the blind SDP timeout."""
+
+ def responder(process: FakeProcess, message: dict[str, Any]) -> None:
+ if _respond_handshake(process, message):
+ return
+ request_id = message.get("id")
+ if not isinstance(request_id, int):
+ return
+ method = message.get("method")
+ if method == "thread/start":
+ _respond(process, request_id, {"thread": {"id": "voice-thread"}})
+ elif method == "thread/realtime/start":
+ process.emit(
+ {
+ "method": "thread/realtime/error",
+ "params": {
+ "threadId": "voice-thread",
+ "message": "unexpected status 403 Forbidden: Voice session access denied.",
+ },
+ }
+ )
+ _respond(process, request_id, {})
+
+ SpawnHarness(monkeypatch, [responder])
+ client = CodexAppServerClient()
+ await client.thread_start(base_instructions="Answer directly.")
+
+ with pytest.raises(CodexAppServerError, match="Voice session access denied"):
+ await client.realtime_start(
+ "voice-thread",
+ offer_sdp="offer-sdp",
+ include_startup_context=False,
+ client_managed_handoffs=True,
+ )
+ await client.close()
+
+
@pytest.mark.asyncio
async def test_realtime_start_forces_handoff_and_startup_context_boundaries(
monkeypatch: pytest.MonkeyPatch,