feat(kagent-adk): improve exception handling for uncatched errors#1278
Merged
EItanya merged 9 commits intokagent-dev:mainfrom Feb 12, 2026
Merged
Conversation
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves runtime failure signaling for ADK-backed A2A execution by (1) handling asyncio.CancelledError explicitly so a final failed status is emitted, and (2) introducing an MCP toolset wrapper that enriches cancelled errors with more context before they propagate.
Changes:
- Catch and publish a final failed status event on
asyncio.CancelledErrorduring request execution. - Add
EnrichedMcpToolsetto enrich MCP session setupCancelledErrors and use it for HTTP/SSE MCP tools. - Update proxy integration tests to assert the agent uses
EnrichedMcpToolsetinstead of relying on class name matching.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/packages/kagent-adk/src/kagent/adk/_agent_executor.py | Adds CancelledError handling and refactors failure event publishing into a shielded helper. |
| python/packages/kagent-adk/src/kagent/adk/_mcp_toolset.py | Introduces EnrichedMcpToolset to rethrow enriched CancelledErrors during MCP tool discovery. |
| python/packages/kagent-adk/src/kagent/adk/types.py | Switches MCP tool construction to use EnrichedMcpToolset for both HTTP and SSE configs. |
| python/packages/kagent-adk/tests/unittests/test_proxy_integration.py | Updates tests to locate MCP toolsets via isinstance(..., EnrichedMcpToolset). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
…h failure event to be consumed Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
a2c570f to
95530fb
Compare
Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io>
EItanya
approved these changes
Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves error handling in the main agent execution function by catching the cancelledError type which is thrown on failures such as tcp connection issues.
Currently, cancelledError's are not properly handled by our exception catching logic as errors that are not subclasses of the
Exceptionclass do not have final statuses emitted. This results in scenarios where an unhandled exception is thrown which causes the runner to close but the consumer continues to wait for an event to dequeue.In addition to properly handling canceledError's, this PR proposes a change to use a custom MCPToolset which enriches cancelled errors with additional context before the error is caught in the main execution function. This provides better visibility into where the error originates from.