Skip to content

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Oct 25, 2025

  • Adds new CodeInterpreterToolCallContent and CodeInterpreterToolResultContent types
  • Updates the OpenAI Assistants and Responses IChatClient implementations to produce them
  • Updates HostedFileContent with an optional MediaType and Name, matching the corresponding properties on DataContent and UriContent.
  • Updates ToChatResponse{Async} coalescing to handle these code interpreter types.
  • Updates DataContent's DebuggerDisplay to show text for "text/*" and "application/json" media types.

Contributes to #6057

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from a team as a code owner October 25, 2025 04:04
Copilot AI review requested due to automatic review settings October 25, 2025 04:04
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Oct 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces new content types for representing code interpreter tool interactions in hosted AI services, specifically adding CodeInterpreterToolCallContent and CodeInterpreterToolResultContent. These types enable better modeling of code execution workflows in OpenAI's Assistants and Responses APIs.

Key changes:

  • New content types for code interpreter tool calls and results
  • Enhanced HostedFileContent with optional MediaType and Name properties to align with DataContent and UriContent
  • Updated coalescing logic to handle the new code interpreter content types

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
CodeInterpreterToolCallContent.cs Defines new content type for code interpreter tool invocations
CodeInterpreterToolResultContent.cs Defines new content type for code interpreter execution results
HostedFileContent.cs Adds MediaType and Name properties with validation
ChatResponseExtensions.cs Updates coalescing logic to merge code interpreter content
OpenAIResponsesChatClient.cs Implements conversion from OpenAI responses to new content types
OpenAIAssistantsChatClient.cs Implements streaming support for code interpreter updates
OpenAIClientExtensions.cs Adds helper to determine image media types from URIs
DataContent.cs Enhances debugger display for text and JSON content
AIJsonUtilities.Defaults.cs Registers new content types for serialization
HostedFileContentTests.cs Adds tests for new MediaType and Name properties
CodeInterpreterToolCallContentTests.cs Adds comprehensive tests for new content type
CodeInterpreterToolResultContentTests.cs Adds comprehensive tests for new content type
OpenAIResponseClientTests.cs Adds integration tests for code interpreter scenarios
Various test files Updates to use collection expressions
Comments suppressed due to low confidence (1)

src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs:1

  • Inconsistent quote escaping in debugger display strings. Line 243 properly escapes the text content with \\\", but line 248 only has a closing quote without proper escaping. Line 248 should be: return $\"JSON = \\\"{Encoding.UTF8.GetString(Data.ToArray())}\\\"\";
// Licensed to the .NET Foundation under one or more agreements.

@stephentoub
Copy link
Member Author

cc: @rogerbarreto, @eavanvalkenburg

stephentoub and others added 3 commits October 29, 2025 11:32
- Adds new CodeInterpreterToolCallContent and CodeInterpreterToolResultContent types
- Updates the OpenAI Assistants and Responses IChatClient implementations to produce them
- Updates HostedFileContent with an optional MediaType and Name, matching the corresponding properties on DataContent and UriContent.
- Updates ToChatResponse{Async} coalescing to handle these code interpreter types.
- Updates DataContent's DebuggerDisplay to show text for "text/*" and "application/json" media types.
…deInterpreterToolCallContent.cs

Co-authored-by: Roger Barreto <[email protected]>
@stephentoub stephentoub force-pushed the codeinterpretercontent branch from b05748b to 323db59 Compare October 29, 2025 17:11
@stephentoub stephentoub enabled auto-merge (squash) October 29, 2025 17:13
@stephentoub stephentoub merged commit f3f1017 into dotnet:main Oct 30, 2025
6 checks passed
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Nov 1, 2025
* Add CodeInterpreterToolCall/ResultContent content types

- Adds new CodeInterpreterToolCallContent and CodeInterpreterToolResultContent types
- Updates the OpenAI Assistants and Responses IChatClient implementations to produce them
- Updates HostedFileContent with an optional MediaType and Name, matching the corresponding properties on DataContent and UriContent.
- Updates ToChatResponse{Async} coalescing to handle these code interpreter types.
- Updates DataContent's DebuggerDisplay to show text for "text/*" and "application/json" media types.

* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs

Co-authored-by: Roger Barreto <[email protected]>

* Address PR feedback

---------

Co-authored-by: Roger Barreto <[email protected]>
jeffhandley pushed a commit that referenced this pull request Nov 2, 2025
* Add CodeInterpreterToolCall/ResultContent content types

- Adds new CodeInterpreterToolCallContent and CodeInterpreterToolResultContent types
- Updates the OpenAI Assistants and Responses IChatClient implementations to produce them
- Updates HostedFileContent with an optional MediaType and Name, matching the corresponding properties on DataContent and UriContent.
- Updates ToChatResponse{Async} coalescing to handle these code interpreter types.
- Updates DataContent's DebuggerDisplay to show text for "text/*" and "application/json" media types.

* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs

Co-authored-by: Roger Barreto <[email protected]>

* Address PR feedback

---------

Co-authored-by: Roger Barreto <[email protected]>
This was referenced Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants