Skip to content

Python: Improve Json parsing for declarative workflow - #7550

Open
Peter Ibekwe (peibekwe) wants to merge 2 commits into
microsoft:mainfrom
peibekwe:declarative-bugfix-python
Open

Python: Improve Json parsing for declarative workflow#7550
Peter Ibekwe (peibekwe) wants to merge 2 commits into
microsoft:mainfrom
peibekwe:declarative-bugfix-python

Conversation

@peibekwe

Copy link
Copy Markdown
Contributor

Motivation & Context

Improve Json parsing in declarative workflow

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 23:27
@peibekwe
Peter Ibekwe (peibekwe) marked this pull request as ready for review August 6, 2026 23:39

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Improves JSON extraction/parsing from agent responses in the declarative workflow executor, with more robust handling of fenced code blocks and malformed/streamed JSON segments.

Changes:

  • Replaced regex-based fenced code parsing with a deterministic fenced-block iterator and “qualified fence first” precedence.
  • Added bounded JSON “recovery” scanning to safely extract the last valid JSON object/array from mixed text.
  • Expanded unit tests to cover multiple fences, invalid/partial candidates, scalars, CRLF, and escape/bracket edge cases.

Reviewed changes

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

File Description
python/packages/declarative/agent_framework_declarative/_workflows/_executors_agents.py Implements new fenced-block iteration and bounded recovery scanning for JSON extraction.
python/packages/declarative/tests/test_graph_executors.py Adds extensive unit tests covering new JSON extraction behaviors and edge cases.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 7, 2026
@github-actions github-actions Bot changed the title Improve Json parsing for declarative workflow Python: Improve Json parsing for declarative workflow Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/declarative/agent_framework_declarative/_workflows
   _executors_agents.py5237885%192, 215, 307, 310–311, 319–320, 330, 341–346, 612, 650–652, 655, 671, 687–691, 715, 720, 810, 816–821, 828, 852–853, 862–864, 913–914, 922, 941, 1048–1051, 1058–1059, 1068–1069, 1081–1086, 1090–1091, 1093, 1098, 1100, 1104–1107, 1110, 1112–1113, 1116, 1124–1126, 1128, 1131–1132, 1134
TOTAL45790424190% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9329 36 💤 0 ❌ 0 🔥 2m 27s ⏱️

@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.

Agent Framework Review — Iteration 1

Completed passes: 4 | Result: Partial

Scope: full PR (1 commit(s)): d5e999abf77b

Review passes

  • Correctness (gpt-5.6-sol) — The three-pass recovery cap can miss valid JSON after three malformed openings, regressing prior recovery behavior.
  • Security Reliability (claude-opus-4.8) — No issues found in this pass.
  • Test Coverage (gpt-5.6-sol) — No issues found in this pass.
  • Design Approach (claude-opus-4.8) — No issues found in this pass.

@moonbox3

Copy link
Copy Markdown
Contributor

/review

@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.

Agent Framework Review — Iteration 1

Completed passes: 4 | Result: Partial

Scope: full PR (1 commit(s)): d5e999abf77b

Review passes

  • Security Reliability (claude-opus-4.8) — No issues found in this pass.
  • Test Coverage (gpt-5.6-sol) — No issues found in this pass.
  • Failure Modes (claude-opus-4.8) — No issues found in this pass.
  • Design Approach (claude-opus-4.8) — No issues found in this pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants