microsoft/autogen · error · ValueError

Progress ledger should contain a single JSON object, but fou

Error message

Progress ledger should contain a single JSON object, but found: {len(progress_ledger)}

What it means

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.

Source

Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py:336

        for _ in range(self._max_json_retries):
            if self._model_client.model_info.get("structured_output", False):
                response = await self._model_client.create(
                    self._get_compatible_context(context), json_output=LedgerEntry
                )
            elif self._model_client.model_info.get("json_output", False):
                response = await self._model_client.create(
                    self._get_compatible_context(context), cancellation_token=cancellation_token, json_output=True
                )
            else:
                response = await self._model_client.create(
                    self._get_compatible_context(context), cancellation_token=cancellation_token
                )
            ledger_str = response.content
            try:
                assert isinstance(ledger_str, str)
                output_json = extract_json_from_str(ledger_str)
                if len(output_json) != 1:
                    raise ValueError(
                        f"Progress ledger should contain a single JSON object, but found: {len(progress_ledger)}"
                    )
                progress_ledger = output_json[0]

                # If the team consists of a single agent, deterministically set the next speaker
                if len(self._participant_names) == 1:
                    progress_ledger["next_speaker"] = {
                        "reason": "The team consists of only one agent.",
                        "answer": self._participant_names[0],
                    }

                # Validate the structure
                required_keys = [
                    "is_request_satisfied",
                    "is_progress_being_made",
                    "is_in_loop",
                    "instruction_or_question",
                    "next_speaker",

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. 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.
  2. Ensure the model_client passed to MagenticOneGroupChat is a ChatCompletionClient with json_output support.
  3. Retry the run — the orchestrator retries ledger parsing a few times before giving up; transient malformed output may pass on retry.
  4. 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.

Example fix

# before
team = MagenticOneGroupChat(
    participants=[...],
    model_client=weak_local_client,  # ignores JSON ledger instructions
)

# after
team = MagenticOneGroupChat(
    participants=[...],
    model_client=AzureOpenAIChatCompletionClient(model="gpt-4o", ...),  # reliable JSON output
)
Defensive patterns

Strategy: retry

Try / catch

try:
    result = await team.run(task=task)
except ValueError as e:
    if "single JSON object" in str(e):
        await team.reset()
        result = await team.run(task=task)  # ledger output is nondeterministic
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/3a8eb0376ae39eb6. Report an issue: GitHub.