Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

fix(integrations): openai/openai-agents: convert input message format#5248

Open
constantinius wants to merge 24 commits intomaster from
constantinius/fix/integrations/openai-report-image-inputs
Open

fix(integrations): openai/openai-agents: convert input message format #5248
constantinius wants to merge 24 commits intomaster from
constantinius/fix/integrations/openai-report-image-inputs

Conversation

@constantinius
Copy link
Contributor

@constantinius constantinius commented Dec 17, 2025
edited
Loading

sentry[bot] reacted with hooray emoji
Copy link

linear bot commented Dec 17, 2025
edited
Loading

@constantinius constantinius changed the title (削除) test(integrations): add test for message conversion (削除ここまで) (追記) fix(openai): convert input message format (追記ここまで) Dec 17, 2025
@constantinius constantinius marked this pull request as ready for review January 8, 2026 08:34
@constantinius constantinius requested a review from a team as a code owner January 8, 2026 08:34
@constantinius constantinius changed the title (削除) fix(openai): convert input message format (削除ここまで) (追記) fix(integrations): openai/openai-agents: convert input message format (追記ここまで) Jan 8, 2026
Base automatically changed from constantinius/fix/redact-message-parts-type-blob to master January 13, 2026 09:56
Copy link
Contributor

github-actions bot commented Jan 13, 2026
edited
Loading

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • feat(anthropic): Set system instruction attribute by alexander-alderman-webb in #5353
  • feat(asyncio): Allow to turn task spans off by sentrivana in #5367
  • feat(gen_ai): add function set_conversation_id and managing functions on the Scope and apply it on the Span on .finish() by constantinius in #5362
  • feat(google-genai): Set system instruction attribute by alexander-alderman-webb in #5354
  • feat(integrations): openai-agents streaming support by constantinius in #5291
  • feat(langchain): Set system instruction attribute by alexander-alderman-webb in #5357
  • feat(openai-agents): Set system instruction attribute by alexander-alderman-webb in #5355
  • feat(pydantic-ai): Set system instruction attribute by alexander-alderman-webb in #5356

Bug Fixes 🐛

  • fix(integrations): openai/openai-agents: convert input message format by constantinius in #5248

Internal Changes 🔧

  • ci(release): Fix changelog-preview permissions by BYK in #5368
  • ci: Fix path in AI integration tests by alexander-alderman-webb in #5347

🤖 This preview updates automatically when you update the PR.

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

Looks ok to me, two things:

  • Can we add a check to the tests that we're not modifying the user's messages? Either as a new test or just adding an assert to the tests added in this PR
  • I assume there is no way to dedupe some of the trimming logic between OpenAI agents and OpenAI because the format is different?

Copy link
Contributor Author

Can we add a check to the tests that we're not modifying the user's messages? Either as a new test or just adding an assert to the tests added in this PR

Done

I assume there is no way to dedupe some of the trimming logic between OpenAI agents and OpenAI because the format is different?

Looking into that. Cursor says no. But I'm not sure tbh

... of full message dicts
- Extract choice.message.content for gen_ai.response.text instead of model_dump()
- Add separate gen_ai.response.tool_calls extraction for Chat Completions API
- Handle audio transcripts in responses
- Extract shared extract_response_output() to ai/utils.py for Responses API output
- Refactor OpenAI and OpenAI Agents integrations to use shared utility
Copy link
Contributor Author

I assume there is no way to dedupe some of the trimming logic between OpenAI agents and OpenAI because the format is different?

I did investigate that. I did eliminate code duplication for output messages, but input messages are actually different

...AI messages
Add transform_content_part() and transform_message_content() functions
to standardize content part handling across all AI integrations.
These functions transform various SDK-specific formats (OpenAI, Anthropic,
Google, LangChain) into a unified format:
- blob: base64-encoded binary data
- uri: URL references (including file URIs)
- file: file ID references
Also adds get_modality_from_mime_type() helper to infer content modality
(image/audio/video/document) from MIME types.
Replace local _convert_message_parts function with the shared
transform_message_content function to deduplicate code across
AI integrations.
Add dedicated transform functions for each AI SDK:
- transform_openai_content_part() for OpenAI/LiteLLM image_url format
- transform_anthropic_content_part() for Anthropic image/document format
- transform_google_content_part() for Google GenAI inline_data/file_data
- transform_generic_content_part() for LangChain-style generic format
Refactor transform_content_part() to be a heuristic dispatcher that
detects the format and delegates to the appropriate specific function.
This allows integrations to use the specific function directly for
better performance and clarity, while maintaining backward compatibility
through the dispatcher for frameworks that can receive any format.
Added 38 new unit tests for the SDK-specific functions.
Replace generic transform_message_content with the OpenAI-specific
transform_openai_content_part function for better performance and
clarity since we know OpenAI always uses the image_url format.
constantinius added a commit that referenced this pull request Jan 19, 2026
### Description
Follow up for #5248 that
was auto-merged too soon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sentry sentry[bot] sentry[bot] left review comments

@cursor cursor[bot] cursor[bot] left review comments

@sentrivana sentrivana Awaiting requested review from sentrivana

@alexander-alderman-webb alexander-alderman-webb Awaiting requested review from alexander-alderman-webb

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /