The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(relay): document stream priming boundary
Alex Fournier256d7efbfd74
diff --git a/agent/relay_llm.py b/agent/relay_llm.pyindex 610deff98ff..6a5669d6e5d 100644--- a/agent/relay_llm.py+++ b/agent/relay_llm.py@@ -286,6 +286,11 @@ def stream_current(own ``hasattr(stream, "choices")`` check handled it (#11732, #55933) —without the unwrap the response stays trapped as ``final_response`` on theinner ManagedLlmStream and the outer consumer sees an empty stream.++ Determining that return shape requires starting a lazy managed pipeline.+ The first pull therefore happens before this function returns: a genuine+ first chunk is buffered, while provider latency and errors surface at the+ same call boundary as the unmanaged ``stream_factory(request)`` path."""turn = relay_runtime.active_turn()if turn is None:diff --git a/tests/agent/test_relay_llm.py b/tests/agent/test_relay_llm.pyindex 67dad0fc471..836eeedcfb0 100644--- a/tests/agent/test_relay_llm.py+++ b/tests/agent/test_relay_llm.py@@ -860,6 +860,23 @@ def test_stream_current_preserves_real_relay_interceptor_chunks(relay_turn):)+def test_stream_current_surfaces_managed_factory_error_before_return(relay_turn):+ """Shape detection preserves the unmanaged factory-error boundary."""++ def fail_factory(_request):+ raise RuntimeError("provider failed before streaming")++ with pytest.raises(RuntimeError, match="provider failed before streaming"):+ relay_llm.stream_current(+ {"model": "test-model", "messages": [], "stream": True},+ fail_factory,+ name="test-provider",+ model_name="test-model",+ finalizer=dict,+ completed_response_predicate=_choices_predicate,+ )++def _completed_response(content: str = "done") -> SimpleNamespace:return SimpleNamespace(model="test-model",