Python: Improve Json parsing for declarative workflow - #7550
Python: Improve Json parsing for declarative workflow#7550Peter Ibekwe (peibekwe) wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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. |
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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.
|
/review |
There was a problem hiding this comment.
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.
Motivation & Context
Improve Json parsing in declarative workflow
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.