fix(temporal): disable OpenAI Agents SDK trace exporter under Temporal workers#403
Open
declan-scale wants to merge 1 commit into
Open
fix(temporal): disable OpenAI Agents SDK trace exporter under Temporal workers#403declan-scale wants to merge 1 commit into
declan-scale wants to merge 1 commit into
Conversation
…l workers The OpenAI Agents SDK registers a process-global BackendSpanExporter that POSTs spans to api.openai.com/v1/traces. Under Temporal the run's trace context does not survive the workflow->activity hop, so spans created in activities have no active trace and are emitted as NoOpSpans (trace_id="no-op"). The exporter then rejects every turn with 400 "Invalid 'data[0].trace_id': 'no-op'", flooding worker logs and running a failing background export thread. Agentex never uses this exporter — it has its own SGP tracing pipeline (AsyncTracer / SGPTracingProcessor), wholly separate from the OpenAI SDK trace provider. Disable it whenever an OpenAIAgentsPlugin is present. Must be the OPENAI_AGENTS_DISABLE_TRACING env var, not agents.set_tracing_disabled(): the plugin installs a fresh TemporalTraceProvider at startup whose `_disabled` is re-read from that env var in __init__, so a prior set_tracing_disabled() call is discarded (verified). setdefault preserves an explicit operator override. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Agents running under the Temporal
OpenAIAgentsPluginflood worker logs with, on every turn:The OpenAI Agents SDK registers a process-global
BackendSpanExporterthat POSTs spans toapi.openai.com/v1/traces. Under Temporal, the run's trace context does not survive the workflow→activity hop, so spans created in activities have no active trace and come out asNoOpSpans (trace_id="no-op"). The exporter then 400s on every turn and runs a failing background export thread.Agentex never uses this exporter — it has its own SGP tracing pipeline (
AsyncTracer/SGPTracingProcessor), wholly separate from the OpenAI SDK trace provider.Fix
In
get_temporal_client, when anOpenAIAgentsPluginis present, setOPENAI_AGENTS_DISABLE_TRACING=1(viasetdefault, so an explicit operator override is preserved).Why the env var (and not
set_tracing_disabled())The plugin installs a fresh
TemporalTraceProviderat worker/client startup. Its__init__(viaDefaultTraceProvider) re-reads_disabledfromOPENAI_AGENTS_DISABLE_TRACING— so any prioragents.set_tracing_disabled(True)is discarded. The env var is the only mechanism that survives the provider swap. Verified:With
_disabled=True,create_trace/create_spanshort-circuit to NoOp before the "No active trace" log and before any processor dispatch — so no spans are created and nothing is exported to OpenAI. SGP tracing is unaffected (separate pipeline).Testing
ruff checkclean on the changed file.mypyerror count unchanged (21 → 21, all pre-existingno-untyped-call/missing-import); no new errors.DefaultTraceProvider(the base ofTemporalTraceProvider).🤖 Generated with Claude Code
Greptile Summary
This PR disables OpenAI Agents SDK tracing when Temporal workers use the OpenAI Agents plugin. It changes:
OPENAI_AGENTS_DISABLE_TRACINGdefault in the worker Temporal client helper.OpenAIAgentsPluginis present.setdefault.Confidence Score: 3/5
This is close, but I would fix this before merging.
OpenAIAgentsPlugincan keep the exporter enabled and still hit the noisy trace export path.src/agentex/lib/core/clients/temporal/utils.pyshould mirror the worker helper behavior.What T-Rex did
Important Files Changed
Comments Outside Diff (1)
src/agentex/lib/core/clients/temporal/utils.py, line 124 (link)The ACP/client helper has the same
OpenAIAgentsPlugindetection path as the worker helper, but it never setsOPENAI_AGENTS_DISABLE_TRACING.TemporalClient.create()passes configured plugins through this helper, so an ACP process usingTemporalACPConfig(plugins=[OpenAIAgentsPlugin(...)])can still leave the OpenAI Agents SDK exporter enabled and keep producing the trace export errors this PR is meant to stop. Please mirror the worker-sidesetdefault("OPENAI_AGENTS_DISABLE_TRACING", "1")behavior here as well.Artifacts
Repro attempt output and source analysis summary
Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(temporal): disable OpenAI Agents SDK..." | Re-trigger Greptile