1+ """OpenAI Agents SDK Temporal Plugin with Streaming Support.
2+
3+ This module provides streaming capabilities for the OpenAI Agents SDK in Temporal
4+ using interceptors to thread task_id through workflows to activities.
5+
6+ The streaming implementation works by:
7+ 1. Using Temporal interceptors to thread task_id through the execution
8+ 2. Streaming LLM responses to Redis in real-time from activities
9+ 3. Returning complete responses to maintain Temporal determinism
10+
11+ Example:
12+ >>> from agentex.lib.core.temporal.plugins.openai_agents import (
13+ ... TemporalStreamingModelProvider,
14+ ... TemporalTracingModelProvider,
15+ ... ContextInterceptor,
16+ ... )
17+ >>> from temporalio.contrib.openai_agents import OpenAIAgentsPlugin, ModelActivityParameters
18+ >>> from datetime import timedelta
19+ >>>
20+ >>> # Create streaming model provider
21+ >>> model_provider = TemporalStreamingModelProvider()
22+ >>>
23+ >>> # Create STANDARD plugin with streaming model provider
24+ >>> plugin = OpenAIAgentsPlugin(
25+ ... model_params=ModelActivityParameters(
26+ ... start_to_close_timeout=timedelta(seconds=120),
27+ ... ),
28+ ... model_provider=model_provider,
29+ ... )
30+ >>>
31+ >>> # Register interceptor with worker
32+ >>> interceptor = ContextInterceptor()
33+ >>> # Add interceptor to worker configuration
34+ """
35+
36+ from agentex .lib .core .temporal .plugins .openai_agents import (
37+ ContextInterceptor ,
38+ TemporalStreamingHooks ,
39+ TemporalStreamingModel ,
40+ TemporalTracingModelProvider ,
41+ TemporalStreamingModelProvider ,
42+ streaming_task_id ,
43+ streaming_trace_id ,
44+ stream_lifecycle_content ,
45+ streaming_parent_span_id ,
46+ )
47+
48+ __all__ = [
49+ "TemporalStreamingModel" ,
50+ "TemporalStreamingModelProvider" ,
51+ "TemporalTracingModelProvider" ,
52+ "ContextInterceptor" ,
53+ "streaming_task_id" ,
54+ "streaming_trace_id" ,
55+ "streaming_parent_span_id" ,
56+ "TemporalStreamingHooks" ,
57+ "stream_lifecycle_content" ,
58+ ]
0 commit comments