fix: wire SGP_CLIENT_BASE_URL and silence openai-agents tracer in templates#352
Merged
danielmillerp merged 1 commit intonextfrom May 8, 2026
Merged
fix: wire SGP_CLIENT_BASE_URL and silence openai-agents tracer in templates#352danielmillerp merged 1 commit intonextfrom
danielmillerp merged 1 commit intonextfrom
Conversation
…plates Two tracing pitfalls hit when running the openai-agents templates against a non-default SGP environment with a LiteLLM proxy key: 1. SGPTracingProcessorConfig hardcoded sgp_base_url=None so traces always went to the SDK default (api.egp.scale.com) regardless of SGP_CLIENT_BASE_URL. Wired the env var through for sync-openai-agents and temporal-openai-agents. sync-langgraph and default-langgraph already had this; no change there. 2. The openai-agents SDK's native tracer ships traces to api.openai.com using OPENAI_API_KEY. When OPENAI_API_KEY is a LiteLLM proxy key the SDK errors with 401 on every request. Calling set_tracing_disabled(True) at module load silences that exporter; SGP traces still flow through the Agentex tracing manager. Also added SGP_CLIENT_BASE_URL to every .env.example.j2 so users see the knob when they copy .env.example to .env. Co-Authored-By: Claude Opus 4.7 (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.
Summary
Two tracing pitfalls hit when running the openai-agents templates against a non-default SGP environment with a LiteLLM proxy key:
SGP_CLIENT_BASE_URLwas being silently dropped. Thesync-openai-agentsandtemporal-openai-agentstemplates constructedSGPTracingProcessorConfigwithoutsgp_base_url, so the SDK fell back to its default host regardless of what the user set in.env. Result: 404s from the wrong SGP environment until you noticed and patched it yourself. (sync-langgraphanddefault-langgraphalready had this wired up — no change needed there.)api.openai.comusingOPENAI_API_KEY, which fails when that key is actually a LiteLLM proxy key (the recommended setup per the templates' own LiteLLM key swap). Callingset_tracing_disabled(True)at module load silences that exporter. SGP traces continue to flow via the Agentex tracing manager.Also added
# SGP_CLIENT_BASE_URL=to every.env.example.j2so the knob is visible when users copy.env.exampleto.env.Files changed
templates/*/.env.example.j2(all 7) — add commentedSGP_CLIENT_BASE_URLtemplates/sync-openai-agents/project/acp.py.j2— wiresgp_base_url+set_tracing_disabled(True)templates/temporal-openai-agents/project/workflow.py.j2— same two fixesTest plan
agentex initforsync-openai-agentsagainst an SGP environment that requires a non-default base URL (e.g. enterprise SGP), setSGP_CLIENT_BASE_URLin.env, and confirm spans land in the dashboardTracing client error 401: ... Incorrect API key provided: sk-...lines appear in logs when running with a LiteLLM proxy key asOPENAI_API_KEYtemporal-openai-agents🤖 Generated with Claude Code
Greptile Summary
This PR fixes two tracing pitfalls in the
sync-openai-agentsandtemporal-openai-agentstemplates: it wiresSGP_CLIENT_BASE_URLintoSGPTracingProcessorConfig(matching the existing langgraph templates) and disables the openai-agents SDK's native tracer to prevent 401s whenOPENAI_API_KEYis a LiteLLM proxy key. All seven.env.example.j2files also gain a commented-outSGP_CLIENT_BASE_URLline for discoverability.Confidence Score: 4/5
Safe to merge — fixes real user-facing bugs with no regressions; only finding is a minor import-ordering style issue in a template file.
All changes are P2 or lower. The fixes are correct and consistent with the pre-existing langgraph template pattern. One style issue (E402 mid-import execution in workflow.py.j2) has no runtime impact but is worth cleaning up in a generated template.
src/agentex/lib/cli/templates/temporal-openai-agents/project/workflow.py.j2 — import ordering style issue
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Module load] --> B[import agents SDK] B --> C["set_tracing_disabled(True)"] C --> D{SGP_API_KEY\n& SGP_ACCOUNT_ID\nset?} D -- Yes --> E["add_tracing_processor_config(\n SGPTracingProcessorConfig(\n sgp_base_url=SGP_CLIENT_BASE_URL\n )\n)"] D -- No --> F[Tracing disabled / no-op] E --> G[SGP Tracing Active\nvia Agentex manager] C --> H[openai-agents native tracer\nsilenced — no calls to\napi.openai.com] G --> I[Spans land in\nSGP dashboard]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix: wire SGP_CLIENT_BASE_URL and silenc..." | Re-trigger Greptile