Skip to content

.NET: Improve string parsing in declarative workflows - #7535

Queued
Peter Ibekwe (peibekwe) wants to merge 1 commit into
microsoft:mainfrom
peibekwe:declarative-bugfix
Queued

.NET: Improve string parsing in declarative workflows#7535
Peter Ibekwe (peibekwe) wants to merge 1 commit into
microsoft:mainfrom
peibekwe:declarative-bugfix

Conversation

@peibekwe

Copy link
Copy Markdown
Contributor

Motivation & Context

Improve string parsing in declarative workflows.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI lite review requested due to automatic review settings August 6, 2026 00:41
@agent-framework-automation agent-framework-automation Bot added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Aug 6, 2026
@github-actions github-actions Bot changed the title Improve string parsing in declarative workflows .NET: Improve string parsing in declarative workflows Aug 6, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 2 | Confidence: 84% | Result: All clear

Reviewed: Correctness, Test Coverage


Automated review by peibekwe's agents

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TrimJsonDelimiter regex parsing with a linear scan to avoid regex backtracking on malformed input.
  • Added new TrimJsonDelimiter tests 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.

@peibekwe
Peter Ibekwe (peibekwe) marked this pull request as ready for review August 6, 2026 00:47

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 2 | Confidence: 93% | Result: All clear

Reviewed: Correctness, Test Coverage


Automated review by peibekwe's agents

@peibekwe
Peter Ibekwe (peibekwe) added this pull request to the merge queue Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants