.NET: [fix] add missing function_approval_response ItemContent type for DevUI approval#6198
Open
hanhan761 wants to merge 2 commits into
Open
.NET: [fix] add missing function_approval_response ItemContent type for DevUI approval#6198hanhan761 wants to merge 2 commits into
hanhan761 wants to merge 2 commits into
Conversation
When a Foreach action iterates over a table with multi-field records, the loop value variable only received the first field of each record due to using .Properties.Values.First() instead of converting the whole record via ToFormula(). Changed to use value.ToFormula() which preserves all fields through the RecordDataValue -> ToRecordValue() conversion path. Fixes microsoft#6183
…I approval Add ItemContentFunctionApprovalResponse to prevent JsonException when DevUI sends a function approval response with type discriminator 'function_approval_response' during HITL tool approval. Previously, the ItemContent polymorphic deserialization would throw 'Read unrecognized type discriminator id function_approval_response' because this type was not registered in the JsonDerivedType attributes. Fixes microsoft#6006
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes foreach iteration over table records to preserve full multi-field record values, and adds support for a new OpenAI response content type for function approval responses.
Changes:
- Update
ForeachExecutorto convert table row values as full formulas (instead of taking only the first field). - Add a regression unit test for multi-field record preservation in foreach.
- Introduce
function_approval_responseas a new polymorphicItemContenttype and add converter handling.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs | Adds regression test coverage for foreach over multi-field table records. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs | Fixes foreach table iteration to preserve complete record values. |
| dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/ItemResource.cs | Adds a new ItemContent derived type for function approval responses. |
| dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Converters/ItemContentConverter.cs | Maps function approval response items into SDK content output. |
| dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/OpenAIHostingJsonUtilities.cs | Registers the new function approval response type for source-gen serialization. |
Comment on lines
+322
to
+323
| // Assert — the value must be present (all fields preserved, not collapsed to first field). | ||
| Assert.True(action.HasValue); |
Comment on lines
+73
to
+75
| // Function approval response - preserve raw representation for downstream processing | ||
| ItemContentFunctionApprovalResponse approvalResponse => | ||
| new TextContent($"[Function approval response: request_id={approvalResponse.RequestId}, approved={approvalResponse.Approved}]"), |
Comment on lines
+463
to
+467
| /// <summary> | ||
| /// Whether the request was approved. | ||
| /// </summary> | ||
| [JsonPropertyName("approved")] | ||
| public bool Approved { get; init; } |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #6006