Skip to content

AnthropicLlm does not translate Anthropic API errors to ADK error codes #5396

Description

@sebastienc

When the Anthropic API returns an error, AnthropicLlm lets the exception propagate unhandled with no helpful context for the developer.

Current behaviour

generate_content_async and _generate_content_streaming have no try/except around the messages.create calls. Errors from the Anthropic SDK (e.g. anthropic.RateLimitError, anthropic.AuthenticationError, anthropic.APIError) bubble up as raw exceptions.

Expected behaviour

Follow the same pattern as google_llm.py:

  • RateLimitError → re-raise as a subclass (AnthropicRateLimitError) with an enhanced message pointing to mitigation steps, matching _ResourceExhaustedError in google_llm.py
  • All other Anthropic exceptions → propagate unchanged

Note: the ADK pattern is to re-raise (with optional enrichment), not to translate exceptions into LlmResponse error fields.

Metadata

Metadata

Labels

models[Component] Issues related to model supportrequest clarification[Status] The maintainer need clarification or more information from the author

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions