[PR #451] [MERGED] fix(deepagents): remove unconditional @langchain/anthropic import #474

Closed
opened 2026-06-05 17:23:18 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/451
Author: @JadenKim-dev
Created: 4/10/2026
Status: Merged
Merged: 4/14/2026
Merged by: @hntrl

Base: mainHead: fix/remove-unconditional-anthropic-import


📝 Commits (3)

  • eec581e fix(deepagents): remove unconditional @langchain/anthropic import
  • 5f010bf Update libs/deepagents/src/agent.ts
  • 622671b Create hot-berries-arrive.md

📊 Changes

2 files changed (+6 additions, -2 deletions)

View changed files

.changeset/hot-berries-arrive.md (+5 -0)
📝 libs/deepagents/src/agent.ts (+1 -2)

📄 Description

Summary

Fixes #443

  • Removed static import { ChatAnthropic } from "@langchain/anthropic" at module level
  • Changed default model parameter from new ChatAnthropic("claude-sonnet-4-6") to the string "claude-sonnet-4-6"

Problem

deepagents@1.9.0 unconditionally imported @langchain/anthropic at the top of agent.ts. Bundlers follow static imports regardless of which model the user actually uses, causing builds to fail for users who only use other providers (e.g. ChatOpenAI) and don't have @langchain/anthropic installed.

Solution

createAgent from langchain natively accepts a model name string (string | AgentLanguageModelLike), so no ChatAnthropic instantiation is needed at the library level. With a string default, bundlers have no static reference to @langchain/anthropic and can tree-shake it entirely.

Users who want Anthropic models can either:

  • Pass new ChatAnthropic(...) explicitly (requires @langchain/anthropic in their own package.json)
  • Rely on the "claude-sonnet-4-6" string default (also requires @langchain/anthropic at runtime, but no longer breaks builds for non-Anthropic users)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/451 **Author:** [@JadenKim-dev](https://github.com/JadenKim-dev) **Created:** 4/10/2026 **Status:** ✅ Merged **Merged:** 4/14/2026 **Merged by:** [@hntrl](https://github.com/hntrl) **Base:** `main` ← **Head:** `fix/remove-unconditional-anthropic-import` --- ### 📝 Commits (3) - [`eec581e`](https://github.com/langchain-ai/deepagentsjs/commit/eec581ebffd5190585af57f6949a1f29625fecb8) fix(deepagents): remove unconditional @langchain/anthropic import - [`5f010bf`](https://github.com/langchain-ai/deepagentsjs/commit/5f010bfb39734d4006dca1b924e04c91c02ae803) Update libs/deepagents/src/agent.ts - [`622671b`](https://github.com/langchain-ai/deepagentsjs/commit/622671bd6e952f1a284775f66d596c2d5fc37f12) Create hot-berries-arrive.md ### 📊 Changes **2 files changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/hot-berries-arrive.md` (+5 -0) 📝 `libs/deepagents/src/agent.ts` (+1 -2) </details> ### 📄 Description ## Summary Fixes #443 - Removed static `import { ChatAnthropic } from "@langchain/anthropic"` at module level - Changed default `model` parameter from `new ChatAnthropic("claude-sonnet-4-6")` to the string `"claude-sonnet-4-6"` ## Problem `deepagents@1.9.0` unconditionally imported `@langchain/anthropic` at the top of `agent.ts`. Bundlers follow static imports regardless of which model the user actually uses, causing builds to fail for users who only use other providers (e.g. `ChatOpenAI`) and don't have `@langchain/anthropic` installed. ## Solution `createAgent` from `langchain` natively accepts a model name string (`string | AgentLanguageModelLike`), so no `ChatAnthropic` instantiation is needed at the library level. With a string default, bundlers have no static reference to `@langchain/anthropic` and can tree-shake it entirely. Users who want Anthropic models can either: - Pass `new ChatAnthropic(...)` explicitly (requires `@langchain/anthropic` in their own `package.json`) - Rely on the `"claude-sonnet-4-6"` string default (also requires `@langchain/anthropic` at runtime, but no longer breaks builds for non-Anthropic users) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 17:23:18 -04:00
yindo closed this issue 2026-06-05 17:23:18 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#474