Feat: Added Anthropic (Claude) model provider support#204
Feat: Added Anthropic (Claude) model provider support#204shkangr wants to merge 5 commits intogoogle:mainfrom
Conversation
Summary of ChangesHello, 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 expands the capabilities of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
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 support for Anthropic's Claude models as an LLM provider. The implementation is well-structured, following the existing BaseLlm abstraction and includes comprehensive unit and E2E tests. My review focuses on improving robustness and clarity. I've pointed out a potential issue with non-unique ID generation for function calls and some inconsistencies and potentially confusing model name identifiers used as defaults and in samples/tests. Overall, this is a great addition to the SDK's capabilities.
|
Thank you for taking the time to open this PR. At the moment, we can't merge this. Specifically, ADK Typescript also has to coordinate with other ADK languages to ensure we have a consistent approach to models other than Google's Gemini. Since we're heading into Cloud Next (late April) and will need to ensure this coordination happens with other teams who are also busy preparing, this will have to be on hold for a while. Also when we're looking at a 1.0 release, this kind of model support is a significant feature that has to be considered carefully. For the 1.0 release, we are not going to have this kind of alternate implementation. In the future, it will likely be included. Once we have a strategy that is shareable, I will update here. You can leave this PR open for the time being, but it will be some time before I can look into it. |
|
This is a desirable feature, would be helpful to check into contrib/ if we haven't set it up yet. Then the conformance and integration questions can be asked later, @ScottMansfield |
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):
2. Or, if no issue exists, describe the change:
If applicable, please follow the issue templates to provide as much detail as
possible.
Problem:
A clear and concise description of what the problem is.
adk-js currently only supports Google Gemini models as the LLM provider. While adk-java already supports Anthropic (Claude) models via Claude.java, adk-js has no equivalent
implementation. This limits users who want to build agents powered by Claude models using the JavaScript/TypeScript SDK.
Solution:
A clear and concise description of what you want to happen and why you choose
this solution.
Add an AnthropicLlm class that extends BaseLlm, following the same provider pattern used by Gemini and ApigeeLlm. The implementation:
or event code are required.
lowercase), and function call ID mapping.
This approach was chosen because it mirrors the adk-java Anthropic implementation while leveraging the existing adk-js BaseLlm abstraction, keeping the change minimal (1 new file + 3 files modified by ~2 lines each) and fully backward-compatible.
Testing Plan
Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.
23 new unit tests added in core/test/models/anthropic_llm_test.ts covering:
connect() (live not supported)
message merging, user message prepend when first message is assistant, system instruction extraction from string and Content object, thought part filtering
Unit Tests:
Please include a summary of passed npm test results.
✓ core/test/models/base_llm_test.ts (6 tests)
✓ core/test/models/registry_test.ts (3 tests)
✓ core/test/models/google_llm_test.ts (12 tests)
✓ core/test/models/anthropic_llm_test.ts (23 tests) ← NEW
✓ core/test/models/apigee_llm_test.ts (43 tests)
Test Files 5 passed (5)
Tests 87 passed (87)
Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.
Set up environment:
Add your Anthropic API key to .env at the project root
▎echo 'ANTHROPIC_API_KEY=sk-ant-...' > .env
Install dependencies and build
▎npm install
▎npm run build
Run the Claude sample agent with the ADK Web UI:
node dev/dist/cli_entrypoint.mjs web dev/samples/claude_agent.ts
Open http://localhost:8000 in browser, select claude_agent, and send a message such as:
▎ Tell me the weather in San Francisco.
Verify that:
- The agent calls the get_weather tool (tool_use → tool_result round-trip)
- The agent returns a final text response based on the tool result
See the screenshot below for expected behavior:
tests/e2e/models/screenshot/screen-shot-adk-js-anthropic.png
The screenshot shows the Claude agent successfully:
Checklist
Additional context
Add any other context or screenshots about the feature request here.