{"record":{"id":"3a8eb0376ae39eb6","repo":"microsoft/autogen","slug":"progress-ledger-should-contain-a-single-json-objec","errorCode":null,"errorMessage":"Progress ledger should contain a single JSON object, but found: {len(progress_ledger)}","messagePattern":"Progress ledger should contain a single JSON object, but found: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py","lineNumber":336,"sourceCode":"        for _ in range(self._max_json_retries):\n            if self._model_client.model_info.get(\"structured_output\", False):\n                response = await self._model_client.create(\n                    self._get_compatible_context(context), json_output=LedgerEntry\n                )\n            elif self._model_client.model_info.get(\"json_output\", False):\n                response = await self._model_client.create(\n                    self._get_compatible_context(context), cancellation_token=cancellation_token, json_output=True\n                )\n            else:\n                response = await self._model_client.create(\n                    self._get_compatible_context(context), cancellation_token=cancellation_token\n                )\n            ledger_str = response.content\n            try:\n                assert isinstance(ledger_str, str)\n                output_json = extract_json_from_str(ledger_str)\n                if len(output_json) != 1:\n                    raise ValueError(\n                        f\"Progress ledger should contain a single JSON object, but found: {len(progress_ledger)}\"\n                    )\n                progress_ledger = output_json[0]\n\n                # If the team consists of a single agent, deterministically set the next speaker\n                if len(self._participant_names) == 1:\n                    progress_ledger[\"next_speaker\"] = {\n                        \"reason\": \"The team consists of only one agent.\",\n                        \"answer\": self._participant_names[0],\n                    }\n\n                # Validate the structure\n                required_keys = [\n                    \"is_request_satisfied\",\n                    \"is_progress_being_made\",\n                    \"is_in_loop\",\n                    \"instruction_or_question\",\n                    \"next_speaker\",","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py#L318-L354","documentation":"While parsing the progress ledger, the MagenticOne orchestrator raises ValueError when the model's JSON output does not contain exactly one JSON object (extract_json_from_str returned zero or multiple objects). Note the message formats len(progress_ledger), which at raise time is a stale/previous-loop value — a cosmetic bug; the real condition is len(output_json) != 1.","triggerScenarios":"The ledger-completion model returns an empty response, prose with no JSON, or multiple concatenated JSON objects; json_output=True not honored by the model/client so the content is free-form text that extracts to 0 or 2+ objects.","commonSituations":"Using a weak local/open model for MagenticOne that ignores the structured ledger prompt; a client that does not support JSON mode; model returns the ledger twice (e.g. reasoning + answer blocks both parse as JSON).","solutions":["Use a model/client that reliably follows the ledger JSON schema and supports JSON output (e.g. Azure OpenAI / OpenAI GPT-4 class models) for MagenticOneGroupChat.","Ensure the model_client passed to MagenticOneGroupChat is a ChatCompletionClient with json_output support.","Retry the run — the orchestrator retries ledger parsing a few times before giving up; transient malformed output may pass on retry.","If it fails consistently, inspect the orchestrator log messages ('Invalid ledger format encountered, retrying...') to see the raw model output and adjust the model or prompt."],"exampleFix":"# before\nteam = MagenticOneGroupChat(\n    participants=[...],\n    model_client=weak_local_client,  # ignores JSON ledger instructions\n)\n\n# after\nteam = MagenticOneGroupChat(\n    participants=[...],\n    model_client=AzureOpenAIChatCompletionClient(model=\"gpt-4o\", ...),  # reliable JSON output\n)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await team.run(task=task)\nexcept ValueError as e:\n    if \"single JSON object\" in str(e):\n        await team.reset()\n        result = await team.run(task=task)  # ledger output is nondeterministic\n    else:\n        raise","preventionTips":["Use a strong JSON-capable model as MagenticOne's model_client.","Watch orchestrator logs for 'Invalid ledger format encountered' to catch this before it surfaces.","Keep tasks/phrasing simple enough that the model can fill the ledger schema."],"tags":["autogen","magentic-one","ledger","json","llm-output"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}