Skip to content

.NET: fix: preserve Foreach record values#6208

Open
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/foreach-preserve-record-values
Open

.NET: fix: preserve Foreach record values#6208
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/foreach-preserve-record-values

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Fixes #6183.

Summary

  • preserve each RecordDataValue as a full record when Foreach materializes table rows
  • add a regression test for a multi-field row so the loop value exposes both fields

To verify

  • dotnet test --project tests\Microsoft.Agents.AI.Workflows.Declarative.UnitTests\Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj -f net10.0 -v Normal --filter-class Microsoft.Agents.AI.Workflows.Declarative.UnitTests.ObjectModel.ForeachExecutorTest
  • dotnet test --project tests\Microsoft.Agents.AI.Workflows.Declarative.UnitTests\Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj -f net472 -v Normal --filter-class Microsoft.Agents.AI.Workflows.Declarative.UnitTests.ObjectModel.ForeachExecutorTest
  • dotnet format agent-framework-dotnet.slnx --verify-no-changes --no-restore --include src\Microsoft.Agents.AI.Workflows.Declarative\ObjectModel\ForeachExecutor.cs tests\Microsoft.Agents.AI.Workflows.Declarative.UnitTests\ObjectModel\ForeachExecutorTest.cs
  • git diff --check

Copilot AI review requested due to automatic review settings May 30, 2026 14:50
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 a bug in ForeachExecutor where iterating over a TableDataValue only exposed the first field of each record instead of the full record.

Changes:

  • Replace value.Properties.Values.First().ToFormula() with value.ToFormula() so the full record is yielded per iteration.
  • Add a unit test verifying multi-field records expose all fields via the loop variable.

Reviewed changes

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

File Description
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/ForeachExecutor.cs Yield full record (not just first property) when iterating a table.
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/ForeachExecutorTest.cs Adds test asserting all record fields are accessible from the iteration variable.

@moonbox3 moonbox3 added .NET workflows Related to Workflows in agent-framework labels May 30, 2026
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]: Declarative Foreach collapses multi-field records to their first field in the loop value variable

3 participants