Skip to content

Commit 72715e7

Browse files
xumapleclaude
andcommitted
AI-18: Move set_tracing_disabled from workflow to worker startup
set_tracing_disabled is a global side effect that shouldn't be called inside deterministic workflow code. Move it to the top of main() in the worker files where it runs once at process startup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ce5d8dd commit 72715e7

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

openai_agents/model_providers/run_gpt_oss_worker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from datetime import timedelta
44
from typing import Optional
55

6-
from agents import Model, ModelProvider, OpenAIChatCompletionsModel
6+
from agents import Model, ModelProvider, OpenAIChatCompletionsModel, set_tracing_disabled
77
from openai import AsyncOpenAI
88
from temporalio.client import Client
99
from temporalio.contrib.openai_agents import ModelActivityParameters, OpenAIAgentsPlugin
@@ -27,6 +27,8 @@ def get_model(self, model_name: Optional[str]) -> Model:
2727

2828

2929
async def main():
30+
set_tracing_disabled(disabled=True)
31+
3032
# Configure logging to show workflow debug messages
3133
logging.basicConfig(level=logging.WARNING)
3234
logging.getLogger("temporalio.workflow").setLevel(logging.DEBUG)

openai_agents/model_providers/run_litellm_provider_worker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
from datetime import timedelta
33

4+
from agents import set_tracing_disabled
45
from agents.extensions.models.litellm_provider import LitellmProvider
56
from temporalio.client import Client
67
from temporalio.contrib.openai_agents import ModelActivityParameters, OpenAIAgentsPlugin
@@ -12,6 +13,8 @@
1213

1314

1415
async def main():
16+
set_tracing_disabled(disabled=True)
17+
1518
# Create client connected to server at the given address
1619
client = await Client.connect(
1720
"localhost:7233",

openai_agents/model_providers/workflows/gpt_oss_workflow.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
from __future__ import annotations
22

3-
from agents import Agent, Runner, function_tool, set_tracing_disabled
3+
from agents import Agent, Runner, function_tool
44
from temporalio import workflow
55

66

77
@workflow.defn
88
class GptOssWorkflow:
99
@workflow.run
1010
async def run(self, prompt: str) -> str:
11-
set_tracing_disabled(disabled=True)
12-
1311
@function_tool
1412
def get_weather(city: str):
1513
workflow.logger.debug(f"Getting weather for {city}")

openai_agents/model_providers/workflows/litellm_auto_workflow.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
from __future__ import annotations
22

3-
from agents import Agent, Runner, function_tool, set_tracing_disabled
3+
from agents import Agent, Runner, function_tool
44
from temporalio import workflow
55

66

77
@workflow.defn
88
class LitellmAutoWorkflow:
99
@workflow.run
1010
async def run(self, prompt: str) -> str:
11-
set_tracing_disabled(disabled=True)
12-
1311
@function_tool
1412
def get_weather(city: str):
1513
return f"The weather in {city} is sunny."

0 commit comments

Comments
 (0)