.NET: Improve string parsing in declarative workflows - #7535
Queued
Peter Ibekwe (peibekwe) wants to merge 1 commit into
Queued
.NET: Improve string parsing in declarative workflows#7535Peter Ibekwe (peibekwe) wants to merge 1 commit into
Peter Ibekwe (peibekwe) wants to merge 1 commit into
Conversation
Peter Ibekwe (peibekwe)
temporarily deployed
to
github-app-auth
August 6, 2026 00:41 — with
GitHub Actions
Inactive
Peter Ibekwe (peibekwe)
temporarily deployed
to
github-app-auth
August 6, 2026 00:41 — with
GitHub Actions
Inactive
Peter Ibekwe (peibekwe)
temporarily deployed
to
github-app-auth
August 6, 2026 00:41 — with
GitHub Actions
Inactive
Peter Ibekwe (peibekwe)
temporarily deployed
to
integration
August 6, 2026 00:41 — with
GitHub Actions
Inactive
Peter Ibekwe (peibekwe)
temporarily deployed
to
integration
August 6, 2026 00:41 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves how declarative workflow code extracts JSON from fenced code blocks by replacing the previous regex-based implementation with a linear scan approach, and expands unit coverage for common LLM output shapes (surrounding text, Windows line endings, multiple fenced blocks, and malformed input).
Changes:
- Replaced
TrimJsonDelimiterregex parsing with a linear scan to avoid regex backtracking on malformed input. - Added new
TrimJsonDelimitertests for surrounding text, Windows line endings, first-block selection, qualifier edge cases, and unterminated fences. - Added a conversion test ensuring fenced JSON strings can be converted into record types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Extensions/StringExtensions.cs | Reworks fenced-JSON trimming to a linear scan implementation (no regex). |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/StringExtensionsTests.cs | Adds coverage for additional fenced-JSON trimming scenarios and edge cases. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/ObjectExtensionsTests.cs | Adds a test validating type conversion from fenced JSON input. |
Peter Ibekwe (peibekwe)
marked this pull request as ready for review
August 6, 2026 00:47
Peter Ibekwe (peibekwe)
temporarily deployed
to
github-app-auth
August 6, 2026 00:47 — with
GitHub Actions
Inactive
westey (westey-m)
approved these changes
Aug 6, 2026
SergeyMenshykh
approved these changes
Aug 6, 2026
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.
Motivation & Context
Improve string parsing in declarative workflows.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.