Skip to content

Conversation

@constantinius
Copy link
Contributor

@constantinius constantinius commented Dec 17, 2025

@linear
Copy link

linear bot commented Dec 17, 2025

@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
@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2026

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(ai): add parse_data_uri function to parse a data URI by constantinius in #5311
  • feat(asyncio): Add on-demand way to enable AsyncioIntegration by sentrivana in #5288
  • feat(openai-agents): Inject propagation headers for HostedMCPTool by alexander-alderman-webb in #5297

Bug Fixes 🐛

  • fix(ai): redact message parts content of type blob by constantinius in #5243
  • fix(clickhouse): Guard against module shadowing by alexander-alderman-webb in #5250
  • fix(gql): Revert signature change of patched gql.Client.execute by alexander-alderman-webb in #5289
  • fix(grpc): Derive interception state from channel fields by alexander-alderman-webb in #5302
  • fix(integrations): openai/openai-agents: convert input message format by constantinius in #5248
  • fix(litellm): Guard against module shadowing by alexander-alderman-webb in #5249
  • fix(pure-eval): Guard against module shadowing by alexander-alderman-webb in #5252
  • fix(ray): Guard against module shadowing by alexander-alderman-webb in #5254
  • fix(threading): Handle channels shadowing by sentrivana in #5299
  • fix(typer): Guard against module shadowing by alexander-alderman-webb in #5253
  • fix: Stop suppressing exception chains in AI integrations by alexander-alderman-webb in #5309
  • fix: Send client reports for span recorder overflow by sentrivana in #5310

Documentation 📚

  • docs(metrics): Remove experimental notice by alexander-alderman-webb in #5304
  • docs: Update Python versions banner in README by sentrivana in #5287

Internal Changes 🔧

Release

  • ci(release): Bump Craft version to fix issues by BYK in #5305
  • ci(release): Switch from action-prepare-release to Craft by BYK in #5290

Other

  • chore(gen_ai): add auto-enablement for google genai by shellmayr in #5295
  • chore: Add type for metric units by sentrivana in #5312
  • ci: Update tox and handle generic classifiers by sentrivana in #5306

🤖 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?

@constantinius
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
@constantinius
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.
elif not isinstance(transformed, list):
transformed = [
{"text": str(transformed), "type": "text"}
]
Copy link

Choose a reason for hiding this comment

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

None content converts to literal string "None"

Medium Severity

When processing message objects in invoke_agent_span, if a message has no content key or content is None, the code converts it to the literal string "None". This happens because msg.get("content") returns None, _transform_openai_agents_message_content(None) returns None, and then str(None) produces "None". A message with missing content would incorrectly display as having content "None" rather than being handled as empty or skipped.

Fix in Cursor Fix in Web

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.

4 participants