mirror of
https://github.com/microsoft/autogen.git
synced 2025-09-03 13:27:41 +00:00
fix(magentic-one): Enhance error handling in orchestrate_step to manage invalid ledger formats (#4845)
* fix(magentic-one): Enhance error handling in orchestrate_step to manage invalid ledger formats * formatting --------- Co-authored-by: Roy Belio <robelio@microsoft.com> Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com> Co-authored-by: Jack Gerrits <jack@jackgerrits.com>
This commit is contained in:
parent
52c2a70e95
commit
00b06ab2e1
@ -297,6 +297,7 @@ class MagenticOneOrchestrator(BaseGroupChatManager):
|
|||||||
for key in required_keys:
|
for key in required_keys:
|
||||||
if (
|
if (
|
||||||
key not in progress_ledger
|
key not in progress_ledger
|
||||||
|
or not isinstance(progress_ledger[key], dict)
|
||||||
or "answer" not in progress_ledger[key]
|
or "answer" not in progress_ledger[key]
|
||||||
or "reason" not in progress_ledger[key]
|
or "reason" not in progress_ledger[key]
|
||||||
):
|
):
|
||||||
@ -305,7 +306,9 @@ class MagenticOneOrchestrator(BaseGroupChatManager):
|
|||||||
if not key_error:
|
if not key_error:
|
||||||
break
|
break
|
||||||
await self._log_message(f"Failed to parse ledger information, retrying: {ledger_str}")
|
await self._log_message(f"Failed to parse ledger information, retrying: {ledger_str}")
|
||||||
except json.JSONDecodeError:
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
key_error = True
|
||||||
|
await self._log_message("Invalid ledger format encountered, retrying...")
|
||||||
continue
|
continue
|
||||||
if key_error:
|
if key_error:
|
||||||
raise ValueError("Failed to parse ledger information after multiple retries.")
|
raise ValueError("Failed to parse ledger information after multiple retries.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user