fix: robust UX for remote agent errors#20307
fix: robust UX for remote agent errors#20307adamfweidman merged 10 commits intogoogle-gemini:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @Shyam-Raghuwanshi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the user experience when interacting with remote A2A agents by replacing generic, unhelpful error messages with structured, user-friendly feedback. It introduces a robust error handling system that classifies various failure modes during agent initialization and execution, such as network issues, authentication problems, or missing agent cards. This change provides users with clear explanations and actionable remediation steps, making it much easier to diagnose and resolve issues with remote agents. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a robust and user-friendly error handling mechanism for remote A2A agent initialization, which is a great improvement over the previous raw error messages. The new typed error classes, classification logic, and comprehensive tests are well-implemented. I've found one area for improvement in packages/core/src/agents/remote-invocation.ts where specific error checks are redundant due to a generic handler. Simplifying this will improve maintainability.
|
Thanks for the contribution, please make sure to sign the CLA @Shyam-Raghuwanshi |
293f1d0 to
508cadd
Compare
|
Hi @adamfweidman, I signed the CLA. |
|
Overall LGTM, left a few comments. Please resolve comments and merge main, also please add some tests for for registry.ts and remote-invocation.ts changes. |
8100901 to
075ad25
Compare
|
This generally looks good to me @Shyam-Raghuwanshi, thanks for the contribution! Can you attach screenshots for some of the Agent Errors? |
|
@Shyam-Raghuwanshi thanks! Can you please include the agent name in the error message? |
8777993 to
2efe13d
Compare
|
@adamfweidman done. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive error handling and classification system for remote agent operations. It defines several custom error types, such as AgentCardNotFoundError and AgentConnectionError, each providing structured, user-friendly messages. A new classifyAgentError utility is implemented to categorize raw errors by thoroughly inspecting their messages and cause chains, including HTTP status codes and network error codes. This system is integrated into the A2AClientManager, AgentRegistry, and RemoteAgentInvocation components to ensure clear and actionable feedback for users when remote agents fail to load or execute. Additionally, the AgentRegistry now includes validation for authentication configurations, emitting warnings if required auth settings are missing. A review comment suggests refactoring the collectErrorMessages helper function to remove duplicated logic for extracting error properties, proposing a unified approach to handle both Error instances and plain objects for improved maintainability and type safety.
|
/gemini review |
4df766c to
21381b9
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors error handling for remote agent interactions by introducing a new set of custom A2AAgentError types and a classifyAgentError utility. The A2AClientManager now uses this utility to classify errors during agent loading, and the AgentRegistry and RemoteAgentInvocation components have been updated to leverage these structured errors, providing more user-friendly messages and emitting appropriate feedback (errors or warnings) to the user. Additionally, the AgentRegistry now validates authentication configurations against agent card security schemes, issuing warnings for missing authentication. The collectErrorMessages function in a2a-errors.ts should be improved to consistently validate the range of HTTP status codes before including them in collected error messages, mirroring the logic applied to plain objects.
There was a problem hiding this comment.
Code Review
This pull request introduces a robust error handling mechanism for remote A2A agent initialization, which is a significant improvement for user experience and debuggability. The introduction of typed error classes in a2a-errors.ts and the classifyAgentError function for inspecting the full error cause chain are well-implemented. The changes are consistently applied across a2a-client-manager, registry, and remote-invocation to ensure that structured, user-friendly error messages are surfaced to the user. The accompanying tests are comprehensive and cover a wide range of error scenarios, including nested and non-standard error objects. Overall, this is a high-quality contribution that enhances the reliability of the A2A agent feature.
…ust-ux-17658 # Conflicts: # packages/core/src/agents/a2a-client-manager.ts
fe3e3b1 to
9852c3f
Compare
Co-authored-by: Adam Weidman <adamfweidman@google.com>
|
@Shyam-Raghuwanshi Thank you for your contribution! |
Co-authored-by: Adam Weidman <adamfweidman@google.com>
Co-authored-by: Adam Weidman <adamfweidman@google.com>
Co-authored-by: Adam Weidman <adamfweidman@google.com>

Add structured error handling for remote A2A agent initialization
with user-friendly error messages and actionable remediation steps.
Problem:
When connecting to remote agents failed (server down, wrong URL,
auth issues), users saw raw 'TypeError: fetch failed' with no
guidance on what went wrong or how to fix it.
Solution:
Add a2a-errors.ts with typed error classes:
HTTP status codes buried in nested .cause objects (including
plain-object causes from HTTP libraries)
Update a2a-client-manager.ts: wrap loadAgent() to rethrow as
classified errors
Update registry.ts: emit user-facing feedback via
coreEvents.emitFeedback() for each error type; validate auth
config against agent card security schemes before registration
Update remote-invocation.ts: add formatExecutionError() for
contextual error messages during agent execution
Add 21 test cases covering all error types, classification logic,
and cause-chain inspection (including plain-object causes)
Fixes: #17658