Skip to content

perf(openai): avoid redundant response serialization - #952

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/trim-openai-serialization-c7e59f5c
Oct 16, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/trim-openai-serialization-c7e59f5c

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Pass raw OpenAI chat and transcription stream events through to aggregation.
  • Avoid dumping non-chat responses and completed Responses objects just to read selected fields.
  • Serialize only Responses output items that produce tool spans; pass agent tool values and annotations through to core logging.
  • Preserve mapping-shaped responses and dict-shaped stream chunks while supporting audio delta objects across OpenAI versions.

Core logging omits bytes: None from streamed logprob entries because the entries now reach bt_safe_deep_copy as Pydantic objects and are dumped with exclude_none=True. _choices_output remains unchanged, preserving refusal: None and tool_calls: None in non-streaming chat output.

Validation

  • nox -s 'test_openai(latest)' -- --vcr-record=none (81 passed)
  • Focused OpenAI coverage on 1.92.0, 1.77.0, and 1.71.0 (19 passed, 1 skipped each)
  • Ruff format/check and commit hooks passed

No cassettes were re-recorded or changed.

Pass raw stream chunks and response objects through to core logging, avoiding repeated conversion while preserving aggregation and tool span behavior.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T00:16:46.861910Z 0b98786 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4463302ebe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/src/braintrust/integrations/openai/tracing.py
Read embeddings and moderation results from either mapping responses or SDK objects without dumping the full response.
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit ccacd8f into main Oct 16, 2026
98 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/trim-openai-serialization-c7e59f5c branch October 16, 2026 00:22
@AbhiPrasad

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant