Fix missing imports in sync-openai-agents template#290
Merged
danielmillerp merged 5 commits intomainfrom Mar 24, 2026
Merged
Conversation
The sync-openai-agents template uses StreamTaskMessageFull and TextContent in the no-API-key error path but never imports them, causing a NameError at runtime. Also adds a missing return after the error yield. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RoxyFarhad
approved these changes
Mar 24, 2026
The top-level import of OpenAIAgentsPlugin in temporal/utils.py triggers the temporalio.contrib.opentelemetry chain which requires opentelemetry-sdk. This breaks all agents (including sync ones) when opentelemetry-sdk is not installed. Moving the import to the only function that uses it (get_temporal_client) avoids this for non-Temporal agents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test runner was using the published SDK for pytest even when --build-cli was set, meaning source fixes weren't reflected in tests. Now uses --with to overlay the local wheel for both the agent process and the test runner. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit edb7a99.
temporalio 1.23.0+ internally imports opentelemetry-sdk via contrib.openai_agents → contrib.opentelemetry. Since we pin temporalio>=1.18.2,<2 and need to support newer versions for CVE fixes, opentelemetry-sdk must be an explicit dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
Summary
sync-openai-agentstemplate (agentex init→ Sync ACP + OpenAI Agents SDK) usesStreamTaskMessageFullandTextContentin the no-API-key error handling path but never imports them, causing aNameErrorat runtimeStreamTaskMessageFullandTextContentreturnafter the error yield so the function doesn't fall through to the OpenAI Runner code when there's no API keyTest plan
agentex init→ Sync ACP + OpenAI Agents SDK and confirming the agent starts without errors🤖 Generated with Claude Code
Greptile Summary
This PR fixes three bugs in the
sync-openai-agentstemplate and makes a related import-hygiene improvement toutils.py.StreamTaskMessageFull(fromagentex.types.task_message_update) andTextContent(fromagentex.types.text_content) were referenced in the no-API-key error path ofhandle_message_sendbut never imported, causing aNameErrorat runtime for any user of the generated template.returnadded: Without thereturnafter the erroryield, the generator would fall through into the OpenAIRunnercode even when no API key is present, causing a secondary runtime failure.utils.py:OpenAIAgentsPluginis moved from a top-level import to a lazy import insideget_temporal_client, avoiding eager loading ofopentelemetry-sdkfor agents that never call into Temporal. The explicitopentelemetry-sdkandopentelemetry-apidependencies added topyproject.tomlformalize what was previously a transitive dependency.Confidence Score: 5/5
NameError, thereturnprevents silent fall-through, and the lazy import is a low-risk refactor with no behaviour change. Thepyproject.toml/lock changes are consistent with the existing transitive dependency. No new logic is introduced and no existing behaviour is altered.Important Files Changed
StreamTaskMessageFullandTextContent, and adds areturnafter the no-API-key error yield to prevent fall-through — all three fixes are correct and necessary.OpenAIAgentsPluginimport from module-level to a lazy import insideget_temporal_clientto avoid eagerly pulling inopentelemetry-sdkfor agents that don't use Temporal; logic is otherwise unchanged.opentelemetry-sdkandopentelemetry-apias explicit direct dependencies, consistent with their previously-transitive usage viatemporalio.opentelemetry-sdkandopentelemetry-apidirect dependencies and version bump from 0.9.3 → 0.9.4.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[handle_message_send called] --> B{OPENAI_API_KEY set?} B -- No --> C[yield StreamTaskMessageFull\nerror message] C --> D[return ✅] B -- Yes --> E[Extract user_prompt\nfrom params] E --> F[Get or create\ntask state] F --> G[Build SyncStreamingProvider\n& RunConfig] G --> H[Initialize Agent\nwith tools] H --> I[Runner.run_streamed] I --> J[convert_openai_to_agentex_events] J --> K[yield agentex_event] K --> J J -- done --> L[Update state\nwith full conversation history]Reviews (5): Last reviewed commit: "Add opentelemetry-sdk as a dependency" | Re-trigger Greptile