Skip to content

Commit 4b5726a

Browse files
danielmillerpclaude
andcommitted
Fix tutorial test failures across sync and temporal agents
- worker.py: Remove private _JSONTypeConverterUnhandled import (removed in newer temporalio) and lazy-import OpenAIAgentsPlugin to avoid opentelemetry.sdk dependency at import time. Fixes all 10 temporal tutorial tests. - 020_streaming/acp.py: Fix TextContent import path and add missing return after error yield. - 030_langgraph/graph.py: Change model from gpt-5 (invalid) to gpt-4o-mini, remove unsupported reasoning parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7f4227f commit 4b5726a

File tree

3 files changed

+7
-6
lines changed
  • examples/tutorials/00_sync
  • src/agentex/lib/core/temporal/workers

3 files changed

+7
-6
lines changed

examples/tutorials/00_sync/020_streaming/project/acp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from agentex.lib.utils.model_utils import BaseModel
1010
from agentex.lib.sdk.fastacp.fastacp import FastACP
1111
from agentex.types.task_message_update import TaskMessageUpdate, StreamTaskMessageFull
12-
from agentex.types.task_message_content import TextContent, TaskMessageContent
12+
from agentex.types.task_message_content import TaskMessageContent
13+
from agentex.types.text_content import TextContent
1314
from agentex.lib.adk.providers._modules.sync_provider import (
1415
SyncStreamingProvider,
1516
convert_openai_to_agentex_events,
@@ -56,6 +57,7 @@ async def handle_message_send(
5657
content="Hey, sorry I'm unable to respond to your message because you're running this example without an OpenAI API key. Please set the OPENAI_API_KEY environment variable to run this example. Do this by either by adding a .env file to the project/ directory or by setting the environment variable in your terminal.",
5758
),
5859
)
60+
return
5961

6062
# Try to retrieve the state. If it doesn't exist, create it.
6163
task_state = await adk.state.get_by_task_and_agent(task_id=params.task.id, agent_id=params.agent.id)

examples/tutorials/00_sync/030_langgraph/project/graph.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from project.tools import TOOLS
2121
from agentex.lib.adk import create_checkpointer
2222

23-
MODEL_NAME = "gpt-5"
23+
MODEL_NAME = "gpt-4o-mini"
2424
SYSTEM_PROMPT = """You are a helpful AI assistant with access to tools.
2525
2626
Current date and time: {timestamp}
@@ -46,7 +46,6 @@ async def create_graph():
4646
"""
4747
llm = ChatOpenAI(
4848
model=MODEL_NAME,
49-
reasoning={"effort": "high", "summary": "auto"},
5049
)
5150
llm_with_tools = llm.bind_tools(TOOLS)
5251

src/agentex/lib/core/temporal/workers/worker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
DefaultPayloadConverter,
2525
CompositePayloadConverter,
2626
JSONPlainPayloadConverter,
27-
_JSONTypeConverterUnhandled,
2827
)
29-
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
3028

3129
from agentex.lib.utils.logging import make_logger
3230
from agentex.lib.utils.registration import register_agent
@@ -45,7 +43,7 @@ def default(self, o: Any) -> Any:
4543

4644
class DateTimeJSONTypeConverter(JSONTypeConverter):
4745
@override
48-
def to_typed_value(self, hint: type, value: Any) -> Any | None | _JSONTypeConverterUnhandled:
46+
def to_typed_value(self, hint: type, value: Any) -> Any | None:
4947
if hint == datetime.datetime:
5048
return datetime.datetime.fromisoformat(value)
5149
return JSONTypeConverter.Unhandled
@@ -96,6 +94,8 @@ async def get_temporal_client(temporal_address: str, metrics_url: str | None = N
9694
_validate_plugins(plugins)
9795

9896
# Check if OpenAI plugin is present - it needs to configure its own data converter
97+
# Lazy import to avoid pulling in opentelemetry.sdk for non-Temporal agents
98+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
9999
has_openai_plugin = any(
100100
isinstance(p, OpenAIAgentsPlugin) for p in (plugins or [])
101101
)

0 commit comments

Comments
 (0)