SIGN IN SIGN UP

fix(deepagents): remove unconditional @langchain/anthropic import (#451)

## 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)

---------

Co-authored-by: Hunter Lovell <40191806+hntrl@users.noreply.github.com>
Y
Youngho Kim committed
79e20e18082a19b65094b953cd857908a7525801
Parent: 4651142
Committed by GitHub <noreply@github.com> on 4/14/2026, 4:46:24 AM