{"record":{"id":"793602c473fad3d9","repo":"microsoft/autogen","slug":"failed-to-parse-ledger-information-after-multiple","errorCode":null,"errorMessage":"Failed to parse ledger information after multiple retries.","messagePattern":"Failed to parse ledger information after multiple retries\\.","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":384,"sourceCode":"                        break\n\n                # Validate the next speaker if the task is not yet complete\n                if (\n                    not progress_ledger[\"is_request_satisfied\"][\"answer\"]\n                    and progress_ledger[\"next_speaker\"][\"answer\"] not in self._participant_names\n                ):\n                    key_error = True\n                    break\n\n                if not key_error:\n                    break\n                await self._log_message(f\"Failed to parse ledger information, retrying: {ledger_str}\")\n            except (json.JSONDecodeError, TypeError):\n                key_error = True\n                await self._log_message(\"Invalid ledger format encountered, retrying...\")\n                continue\n        if key_error:\n            raise ValueError(\"Failed to parse ledger information after multiple retries.\")\n        await self._log_message(f\"Progress Ledger: {progress_ledger}\")\n\n        # Check for task completion\n        if progress_ledger[\"is_request_satisfied\"][\"answer\"]:\n            await self._log_message(\"Task completed, preparing final answer...\")\n            await self._prepare_final_answer(progress_ledger[\"is_request_satisfied\"][\"reason\"], cancellation_token)\n            return\n\n        # Check for stalling\n        if not progress_ledger[\"is_progress_being_made\"][\"answer\"]:\n            self._n_stalls += 1\n        elif progress_ledger[\"is_in_loop\"][\"answer\"]:\n            self._n_stalls += 1\n        else:\n            self._n_stalls = max(0, self._n_stalls - 1)\n\n        # Too much stalling\n        if self._n_stalls >= self._max_stalls:","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py#L366-L402","documentation":"The MagenticOne orchestrator raises ValueError when the progress ledger could not be parsed or validated after its internal retry attempts are exhausted. Each retry re-calls the model; persistent JSONDecodeError, TypeError, or missing required ledger keys (key_error) makes the loop give up.","triggerScenarios":"The ledger model repeatedly returns output that either fails json parsing, extracts to != 1 object, or lacks required keys such as is_request_satisfied / next_speaker / is_in_loop, across all retry iterations of _prepare_next_step.","commonSituations":"Small or local models that cannot follow the complex progress-ledger schema; rate-limited or truncated completions that cut the JSON mid-object; a client that returns non-string content the assert/extract path chokes on.","solutions":["Switch the MagenticOne model_client to a stronger instruction-following model with JSON mode support.","Check logs for 'Failed to parse ledger information, retrying: ...' to see the raw malformed output and address the cause (truncation, wrong schema, prose).","Increase max_turns is not the fix — instead reduce prompt complexity or number of participants so the ledger prompt is easier for the model.","Catch ValueError around run_stream/run_task and surface a clear message to retry the task; MagenticOne's ledger parsing is inherently probabilistic."],"exampleFix":"# before\ntry:\n    await team.run(task=\"...\")\nexcept ValueError as e:  # 'Failed to parse ledger information after multiple retries.'\n    raise\n\n# after\nfrom autogen_agentchat.base import TaskResult\ntry:\n    result = await team.run(task=\"...\")\nexcept ValueError:\n    # retry once with a fresh team state; ledger parsing is model-dependent\n    await team.reset()\n    result = await team.run(task=\"...\")","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        result = await team.run(task=task)\n        break\n    except ValueError as e:\n        if \"Failed to parse ledger\" not in str(e) or attempt == 1:\n            raise\n        await team.reset()","preventionTips":["Prefer frontier models for MagenticOne ledger parsing; local/small models fail often.","Monitor logs of raw ledger output to spot systematic schema failures early.","Treat MagenticOne runs as probabilistic; wrap run() with retry-and-reset in production."],"tags":["autogen","magentic-one","ledger","retry-exhausted","llm-output"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}