Skip to content

.NET: [fix] add missing function_approval_response ItemContent type for DevUI approval#6198

Open
hanhan761 wants to merge 2 commits into
microsoft:mainfrom
hanhan761:fix-6006-devui-approval-discriminator
Open

.NET: [fix] add missing function_approval_response ItemContent type for DevUI approval#6198
hanhan761 wants to merge 2 commits into
microsoft:mainfrom
hanhan761:fix-6006-devui-approval-discriminator

Conversation

@hanhan761
Copy link
Copy Markdown

Fixes #6006

hanhan761 added 2 commits May 30, 2026 14:59
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
Copilot AI review requested due to automatic review settings May 30, 2026 07:18
@moonbox3 moonbox3 added .NET workflows Related to Workflows in agent-framework labels May 30, 2026
Copy link
Copy Markdown
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

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 ForeachExecutor to 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_response as a new polymorphic ItemContent type 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; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: DEVUI Read unrecognized type discriminator id 'function_approval_response'.

3 participants