Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(magentic-one): Enhance error handling in orchestrate_step to manage invalid ledger formats #4845

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ async def _orchestrate_step(self, cancellation_token: CancellationToken) -> None
for key in required_keys:
if (
key not in progress_ledger
or not isinstance(progress_ledger[key], dict)
or "answer" not in progress_ledger[key]
or "reason" not in progress_ledger[key]
):
Expand All @@ -305,7 +306,11 @@ async def _orchestrate_step(self, cancellation_token: CancellationToken) -> None
if not key_error:
break
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
if key_error:
raise ValueError("Failed to parse ledger information after multiple retries.")
Expand Down
Loading