fix(openai): capture web search options and streaming citation annotations - #233
Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit intoSep 14, 2026
Conversation
…ming citation annotations Signed-off-by: atharvamhaske <atharvamhaske76@gmail.com>
Contributor
Author
|
Abhijeet Prasad (@AbhiPrasad) ready for review, just small gap fix |
Abhijeet Prasad (AbhiPrasad)
approved these changes
Sep 14, 2026
Abhijeet Prasad (AbhiPrasad)
merged commit Sep 14, 2026
2a695b2
into
braintrustdata:main
8 checks passed
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
web_search_optionsandpredictionwere missing from Chat Completions request metadata. Both are now captured.annotations. They're now aggregated into the final message alongside content and tool_calls.Verification
Confirmed against real API calls, not just SDK types, using a funded key.
openai-gov1.12.0'sChatCompletionNewParams.WebSearchOptions/Predictionfields are real.gpt-5-search-apiwithweb_search_optionsset showsdelta.annotationson the wire. It arrives whole in one chunk alongsidefinish_reason, not incrementally likecontent.openai-go's typedChatCompletionChunkChoiceDeltastruct, and the Python/Node equivalents, don't declare anannotationsfield at all. The SDK types lag the real API. This tracer parses raw JSON directly instead of the typed struct, so that lag doesn't block the fix.gpt-4o-search-preview/gpt-4o-mini-search-previewmodels are now deprecated. Usedgpt-5-search-apifor the real test call instead.Changes
trace/contrib/openai/chatcompletions.go: addedweb_search_options/predictionto the metadata field list.postprocessStreamingResultsnow accumulatesdelta.annotationsacross chunks into the final message.trace/contrib/openai/chatcompletions_test.go: a unit test onStartSpanfor the metadata fields (no network needed, sinceweb_search_options/predictionrequire specific model support to call live), plus a real VCR-recorded streaming test againstgpt-5-search-apiconfirming annotations survive aggregation.examples/internal/openai-v1/main.go: newchat-web-search-streamingexample.Notes
make ciclean locally.Closes #127