Add CodeInterpreterToolCall/ResultContent content types#6964
Merged
stephentoub merged 4 commits intodotnet:mainfrom Oct 30, 2025
Merged
Add CodeInterpreterToolCall/ResultContent content types#6964stephentoub merged 4 commits intodotnet:mainfrom
stephentoub merged 4 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
HostedFileContentwith optionalMediaTypeandNameproperties to align withDataContentandUriContent - 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.
Member
Author
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs
Show resolved
Hide resolved
eiriktsarpalis
approved these changes
Oct 27, 2025
jozkee
approved these changes
Oct 27, 2025
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolResultContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolResultContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/HostedFileContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/HostedFileContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
rogerbarreto
approved these changes
Oct 28, 2025
jozkee
reviewed
Oct 28, 2025
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs
Show resolved
Hide resolved
- 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 <19890735+rogerbarreto@users.noreply.github.com>
b05748b to
323db59
Compare
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 <19890735+rogerbarreto@users.noreply.github.com>
* Address PR feedback
---------
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
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 <19890735+rogerbarreto@users.noreply.github.com>
* Address PR feedback
---------
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
This was referenced Dec 2, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Contributes to #6057
Microsoft Reviewers: Open in CodeFlow