Python: Parse fenced JSON from the group chat orchestrator agent - #8850
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Conversation
When a provider ignores response_format, the orchestrator agent can return its AgentOrchestrationOutput as JSON wrapped in a Markdown code fence. The parser rejected it, so terminate=true was never applied and the group chat ran until max_rounds. _parse_agent_output now also tries the body of the last fenced block as a parse candidate, after the raw text, so existing behavior is unchanged. Fixes microsoft#8814 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shivam Sharma (ShivamSharma43)
deployed
to
github-app-auth
September 29, 2026 15:12 — with
GitHub Actions
Active
Shivam Sharma (ShivamSharma43)
deployed
to
github-app-auth
September 29, 2026 15:12 — with
GitHub Actions
Active
This branch was successfully deployed
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
AgentBasedGroupChatOrchestratorasks the orchestrator agent for anAgentOrchestrationOutputviaresponse_format. Providers that don't honorresponse_format(for example Claude on Bedrock through an OpenAI-compatible Chat Completions endpoint) return the JSON as plain text wrapped in a Markdown code fence._parse_agent_outputcan't decode fenced JSON, so the orchestration decision, includingterminate: true, is never applied and the group chat runs untilmax_rounds.Description & Review Guide
_parse_agent_outputnow also tries the body of the last Markdown code fence (```json, a bare```, or any language tag) as a parse candidate.ValueError.response_formatnow honor the manager's decisions instead of degrading tomax_rounds. No public API changes._parse_last_json_object).This covers suggested fix (1) from the issue. Fixes (2), exposing
retry_attemptsonGroupChatBuilder, and (3), documentation, are left for separate changes.Related Issue
Fixes #8814
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.🤖 Generated with Claude Code