Skip to content

Commit 00b06ab

Browse files
r-bit-rryRoy Beliojackgerrits
authored
fix(magentic-one): Enhance error handling in orchestrate_step to manage invalid ledger formats (microsoft#4845)
* fix(magentic-one): Enhance error handling in orchestrate_step to manage invalid ledger formats * formatting --------- Co-authored-by: Roy Belio <[email protected]> Co-authored-by: Jack Gerrits <[email protected]> Co-authored-by: Jack Gerrits <[email protected]>
1 parent 52c2a70 commit 00b06ab

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ async def _orchestrate_step(self, cancellation_token: CancellationToken) -> None
297297
for key in required_keys:
298298
if (
299299
key not in progress_ledger
300+
or not isinstance(progress_ledger[key], dict)
300301
or "answer" not in progress_ledger[key]
301302
or "reason" not in progress_ledger[key]
302303
):
@@ -305,7 +306,9 @@ async def _orchestrate_step(self, cancellation_token: CancellationToken) -> None
305306
if not key_error:
306307
break
307308
await self._log_message(f"Failed to parse ledger information, retrying: {ledger_str}")
308-
except json.JSONDecodeError:
309+
except (json.JSONDecodeError, TypeError):
310+
key_error = True
311+
await self._log_message("Invalid ledger format encountered, retrying...")
309312
continue
310313
if key_error:
311314
raise ValueError("Failed to parse ledger information after multiple retries.")

0 commit comments

Comments
 (0)