Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)
Python
fix(smoke): accept reasoning-only streams and add text placeholder
Alishahryar1f96f541c0a69
diff --git a/providers/openai_compat.py b/providers/openai_compat.pyindex 88ff24be..b01f5dad 100644--- a/providers/openai_compat.py+++ b/providers/openai_compat.py@@ -391,6 +391,17 @@ class OpenAIChatTransport(BaseProvider):for event in sse.ensure_text_block():yield eventyield sse.emit_text_delta(" ")+ elif (+ not has_started_tool+ and not sse.accumulated_text.strip()+ and sse.accumulated_reasoning.strip()+ ):+ # Some OpenAI-compatible models (e.g. NIM reasoning templates) stream only+ # ``reasoning_content`` with no ``content``; emit a minimal text block so+ # clients and smoke ``text_content()`` see a completed assistant message.+ for event in sse.ensure_text_block():+ yield event+ yield sse.emit_text_delta(" ")for event in self._flush_task_arg_buffers(sse):yield eventdiff --git a/smoke/prereq/test_provider_prereq_live.py b/smoke/prereq/test_provider_prereq_live.pyindex ed5d5ffd..c5269f10 100644--- a/smoke/prereq/test_provider_prereq_live.py+++ b/smoke/prereq/test_provider_prereq_live.py@@ -8,6 +8,7 @@ import pytestfrom core.anthropic.stream_contracts import (assert_anthropic_stream_contract,text_content,+ thinking_content,)from smoke.lib.config import SmokeConfig, auth_headersfrom smoke.lib.e2e import ProviderMatrixDriver@@ -66,7 +67,11 @@ def test_configured_provider_models_stream_successfully()skip_if_upstream_unavailable_events(events)assert_anthropic_stream_contract(events)- assert text_content(events).strip(), "provider returned no text"+ has_text = bool(text_content(events).strip())+ has_thinking = bool(thinking_content(events).strip())+ assert has_text or has_thinking, (+ "provider returned no visible text or thinking content"+ )except Exception as exc:skip_if_upstream_unavailable_exception(exc)failures.append(diff --git a/tests/providers/test_streaming_errors.py b/tests/providers/test_streaming_errors.pyindex d272c8ed..4bc5ace7 100644--- a/tests/providers/test_streaming_errors.py+++ b/tests/providers/test_streaming_errors.py@@ -302,6 +302,38 @@ class TestStreamingExceptionHandling:assert '"text_delta"' in event_textassert "message_stop" in event_text+ @pytest.mark.asyncio+ async def test_reasoning_only_stream_emits_placeholder_text(self):+ """When the model streams only ``reasoning_content`` (no ``content``), add text block.++ NIM / some templates may emit no main ``content``; a minimal text block matches+ the empty-body placeholder and helps clients that expect a text segment.+ """+ provider = _make_provider_with_thinking_enabled(True)+ request = _make_request()+ chunk1 = _make_chunk(reasoning_content="reasoning only from provider")+ chunk2 = _make_chunk(finish_reason="stop")+ stream_mock = AsyncStreamMock([chunk1, chunk2])+ with (+ patch.object(+ provider._client.chat.completions,+ "create",+ new_callable=AsyncMock,+ return_value=stream_mock,+ ),+ patch.object(+ provider._global_rate_limiter,+ "wait_if_blocked",+ new_callable=AsyncMock,+ return_value=False,+ ),+ ):+ events = await _collect_stream(provider, request)+ event_text = "".join(events)+ assert "thinking_delta" in event_text+ assert '"text_delta"' in event_text+ assert "message_stop" in event_text+@pytest.mark.asyncioasync def test_stream_with_thinking_content(self):"""Thinking content via think tags is emitted as thinking blocks."""