Skip to content

Conversation

tabletcorry
Copy link

Agent tracing was hardcoded against the API endpoint, so any client using a proxy or alternate route to the OpenAI AI endpoint would encounter errors.

So this modify the tracing init code to use OPENAI_BASE_URL when present, if the local environment hasn't overridden anything.

Note: Because this code path is generally executed at import time, the environment variable needs to be set prior to importing any openai-agents code.

@seratch seratch added enhancement New feature or request feature:tracing labels Jul 8, 2025
@seratch seratch requested a review from rm-openai July 8, 2025 13:12
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is generally not a safe backwards compatible change. For example, environments may set OPENAI_BASE_URL to a proxy to allow tracing/cost tracking, but that proxy doens't necessarily support tracing (since only thje specific openai api supports it). Would prefer something more explicit where users opt-in to setting the tracing url.

@tabletcorry
Copy link
Author

Nod, I searched around a fair bit to see if OpenAI had any variable or name for the tracing endpoint, and couldn't find one, so I decided to piggyback instead.

Given the lasting nature of an env var name like this, it seems like something y'all should define, rather than me.

@tabletcorry
Copy link
Author

Also since the token is shared for API access and tracing access, I am not sure how a proxy would work that doesn't support both.

It would be somewhat odd to give someone a real OpenAI token, then tell them to use a proxy with a different token instead.

@seratch
Copy link
Member

seratch commented Jul 16, 2025

@rm-openai Do you think OPENAI_TRACES_INGEST_ENDPOINT env variable (or anything like that) can work? Or do prefer asking devs to instantiate TracingExporter with the endpoint string in code? I don't have strong opinion here.

@rm-openai
Copy link
Collaborator

Yeah let's add a URL method similar to set_tracing_export_api_key().

Copy link
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions bot added the stale label Jul 28, 2025
Copy link
Contributor

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants