-
Notifications
You must be signed in to change notification settings - Fork 1
Implement proper ADK error handling using native error fields instead of sentinel strings #36
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
3b778ba
c6f9c1c
ea5b51e
2b78cd8
608f3a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,16 +54,16 @@ def structured_error_message( | |
| suggestion=suggestion | ||
| ) | ||
|
|
||
| # Create a structured JSON response that the frontend can parse | ||
| error_json = error_response.model_dump_json() | ||
|
|
||
| # Use proper ADK error fields instead of sentinel strings | ||
| return Event( | ||
| author=self.name, | ||
| invocation_id=ctx.invocation_id, | ||
| error_code=error_type, | ||
| error_message=error_response.model_dump_json(), | ||
| content=types.Content( | ||
| role="model", | ||
| parts=[ | ||
| types.Part(text=f"MANUGEN_ERROR: {error_json}"), | ||
| types.Part(text=f"Error: {message}"), | ||
| ], | ||
| ), | ||
| ) | ||
|
Comment on lines
+60
to
+69
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get why it's sending the error back as part of the event stream; I suppose it's the least invasive way to add reporting from the agents through to the frontend. While you can use ADK events to represent errors, the way it's done here only flags it as an error by the presence of a string, "MANUGEN_ERROR: ", preceding the error text. The ADK has a way to flag events as errors, documented here: https://google.github.io/adk-docs/events/#additional-context-and-event-details.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to use proper ADK error fields! Now using |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't quite work: the original content includes paragraph tags, while this only retains the text itself. When the text is replaced on a failure, it ends being one long block of text without breaks that were introduced by those tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! Updated
getContext()to capture the selected content as structured JSON (selJSON) instead of plain text. This preserves the original paragraph structure and formatting when restoring content on error, ensuring paragraph breaks are maintained. (608f3a4)