Skip to content

feat: add Claude LLM integration #281

Open
akhsri wants to merge 5 commits into
google:mainfrom
redbus-labs:aakash/claude-support
Open

feat: add Claude LLM integration #281
akhsri wants to merge 5 commits into
google:mainfrom
redbus-labs:aakash/claude-support

Conversation

@akhsri
Copy link
Copy Markdown

@akhsri akhsri commented Apr 18, 2026

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

  • Closes: N/A
  • Related: N/A

2. Or, if no issue exists, describe the change:

Problem:
The Agent Development Kit (ADK) currently supports Google and Apigee LLMs, but lacks built-in support for Anthropic's Claude models. Developers wishing to build agents powered by the Claude family of models (e.g., Claude 3.5 Sonnet, Claude 3 Haiku) cannot do so out-of-the-box.

Solution:
This PR introduces the Claude class, which extends BaseLlm to integrate Anthropic's Claude models into the ADK framework.

Key additions and technical details:

  • Added @anthropic-ai/sdk as a dependency.
  • Implemented generateContentAsync to interact with the Anthropic Messages API.
  • Added robust support for Tool Use (Function Calling):
    • Added toolsToAnthropicTools and functionDeclarationToAnthropicTool to map ADK's FunctionDeclaration to Anthropic's Tool.InputSchema.
    • Ensured the generated input schema strictly conforms to JSON Schema Draft 2020-12 (a requirement for the Anthropic API), specifically preserving the root type: 'object' structure and correctly lowercasing type definitions via a recursive updateTypeString method.
    • Added conversion logic to map Anthropic's tool_use and tool_result blocks back to ADK's FunctionCall and FunctionResponse structures.
  • Registered the Claude model in LLMRegistry.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Note: I have run npm run build, npm run lint, and npm test locally in the core package and all checks pass successfully.

Manual End-to-End (E2E) Tests:

To manually verify the tool calling functionality with Claude:

  1. Ensure your .env file contains a valid ANTHROPIC_API_KEY.
  2. I created an in-memory agent (@in-mem-agents/index.js) using InMemoryRunner.
  3. I added a parameterized tool (e.g., get_weather with location and unit arguments using zod).
  4. I ran a test script that instantiated the agent with model: 'claude-3-haiku-20240307' and sent a user prompt ("What is the weather in Seattle?").
  5. Result: The agent successfully paused, parsed the arguments, executed the get_weather tool, and returned the formatted response, confirming the JSON schema mapping and tool execution loop work flawlessly with the Anthropic API.
Screenshot 2026-04-19 at 5 19 39 AM

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works. (Note: Added manual E2E validation, unit tests for the adapter can be added in a follow-up if required by maintainers)
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This PR was developed iteratively to ensure strict adherence to Anthropic's JSON Schema Draft 2020-12 requirements, which caused initial invalid_request_error rejections until the root object schema structure was perfectly aligned and exactly matched the expected {"type": "object", "properties": {...}} format.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 18, 2026

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.

@akhsri akhsri changed the title feat: add Claude LLM integration and update dependencies feat: add Claude LLM integration Apr 18, 2026
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.

1 participant