feat(tracing): accept metadata kwarg on all span factories#3155
Open
srikalyan wants to merge 1 commit intoopenai:mainfrom
Open
feat(tracing): accept metadata kwarg on all span factories#3155srikalyan wants to merge 1 commit intoopenai:mainfrom
srikalyan wants to merge 1 commit intoopenai:mainfrom
Conversation
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Extend the optional `metadata` kwarg to every public `*_span()` factory and the matching SpanData subclasses that lacked it (function, generation, response, handoff, custom, guardrail, transcription, speech, speech_group, mcp_tools). Append the new parameter at the end of each signature to preserve positional compatibility. The exporter already serializes `span.span_data.metadata` at the top-level `metadata` key, so no changes are needed in the export pipeline. Backfill the same short Args entry in every helper docstring that documents arguments, so the generated reference picks it up. Note: Partially addresses openai#1844. Does not Close openai#1844, because the active response_span during LLM hooks is still a separate runtime-ordering problem
90d9682 to
1b3e9f5
Compare
Author
|
@codex review |
Member
|
Thanks for sharing this. I don't have the bandwidth to check this suggestion in depth right now, but have you verified if this change works well with the production OpenAI production API endpoint for tracing? The API could reject some data, so verifying the code alone may not be enough for quality assurance. |
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
Extend the optional
metadatakwarg to every public*_span()factory and the matching SpanData subclasses that lacked it (function, generation, response, handoff, custom, guardrail, transcription, speech, speech_group, mcp_tools). Append the new parameter at the end of each signature to preserve positional compatibility.The exporter already serializes
span.span_data.metadataat the top-levelmetadatakey, so no changes are needed in the export pipeline. Backfill the same short Args entry in every helper docstring that documents arguments, so the generated reference picks it up.Test plan
tests/test_tracing.pythat round-trips ametadatadict through every public span factory (13 ids) and verifies it surfaces under the exported payload's top-levelmetadatafield.span.span_data.metadatacan be mutated after construction (e.g. via a direct span reference) and the new value is reflected in the export.make format— cleanmake lint— cleanuv run mypy src/agents/tracing/span_data.py src/agents/tracing/create.py tests/test_tracing.py— cleanuv run pytest tests/test_tracing.py tests/test_agent_tracing.py tests/test_responses_tracing.py tests/test_function_tool.py— 105 passedIssue number
Partially addresses #1844. Does not Close #1844, because the active response_span during LLM hooks is still a separate runtime-ordering problem.
Checks
make lintandmake format