Skip to content

[java/google-adk] make MCP protocol errors non-retryable in MCP activities - #668

Merged
brianstrauch merged 3 commits into
temporalio:mainfrom
pcbeingused333:fix/c4400-adk-mcp-nonretryable
Nov 19, 2026
Merged

brianstrauch merged 3 commits into
temporalio:mainfrom
pcbeingused333:fix/c4400-adk-mcp-nonretryable

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

No separate issue: Java sibling of #549 (and #548, #449), which make MCP protocol errors non-retryable in the Python integrations.

Cause. McpActivitiesImpl.listMcpTools and callMcpTool wrap every RuntimeException in a retryable googleadk.McpError. An McpError for a request a retry cannot fix (invalid params, invalid request, method not found, parse error) therefore stays retryable and, with the default retry policy, is retried until the policy gives up.

Fix. Look up the McpError along the cause chain (the call may wrap it) and, for the JSON-RPC codes PARSE_ERROR, INVALID_REQUEST, METHOD_NOT_FOUND and INVALID_PARAMS, raise the same googleadk.McpError failure as non-retryable, matching python/google_adk. INTERNAL_ERROR, transport errors, timeouts and unknown codes stay retryable. FailureTypes.MCP_ERROR docs updated. The failure type is unchanged, so workflows that match on it keep working. The toolset-factory wrapper uses the same classifier, so a JSON-RPC rejection while a factory initializes its session is classified the same way; startup and transport failures stay retryable.

Test. McpActivitiesImplTest gains cases for each of the four codes (raised by the listing and by the tools/call request), an error behind a wrapper exception, INTERNAL_ERROR staying retryable for both, and a protocol error raised by a toolset factory. The README's MCP failure paragraph is updated.

This change was prepared with the help of an AI assistant (Claude) and submitted by the account owner.

…ities

A JSON-RPC protocol error a retry cannot fix (parse error, invalid request, method not found, invalid params) now fails the activity non-retryably, as python/google_adk does. Other errors stay retryable.
@pcbeingused333
pcbeingused333 requested a review from a team as a code owner November 18, 2026 20:21

@brianstrauch brianstrauch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One documentation issue on the standard ADK tool-call path.

Comment thread java/google-adk/README.md Resolved
…ories

A factory that initializes its MCP session can hit a JSON-RPC rejection such as INVALID_PARAMS; the factory wrapper now uses the same classifier as listing and tool calls. Transport and startup failures stay retryable.

@brianstrauch brianstrauch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants